Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

May 2, 2008

Processing XML with Java


This XML with Java ebooks tutorial™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX is written for experienced Java developers who want to integrate XML into their systems. Java is the ideal language for processing XML documents. Its strong Unicode support in particular made it the preferred language for many early implementers. Consequently, more XML tools have been written in Java than in any other language. More open source XML tools are written in Java than in any other language. More developers process XML in Java than in any other language.

Processing XML with Java™ will teach you how to :
Save XML documents from applications written in Java
Read XML documents produced by other programs
Search, query, and update XML documents
Convert legacy flat data into hierarchical XML
Communicate with network servers that send and receive XML data
Validate documents against DTDs, schemas, and business rules
Combine functional XSLT transforms with traditional imperative Java code

Processing XML with Java™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX is intended for Java developers who need to do anything with XML. It teaches the fundamentals and advanced topics, leaving nothing out. It is a comprehensive course in processing XML with Java that takes developers from having little knowledge of XML to designing sophisticated XML applications and parsing complicated documents. The examples cover a wide range of possible uses, including file formats, data exchange, document transformation, database integration, and more.

Content this ebooks :
Part I. XML
Chapter 1. XML for Data
Motivating XML
XML Syntax
Validity
Stylesheets
Summary

Chapter 2. XML Protocols: XML-RPC and SOAP
XML as a Message Format
HTTP as a Transport Protocol
RSS
Customizing the Request
XML-RPC
SOAP
Custom Protocols
Summary

Chapter 3. Writing XML with Java
Fibonacci Numbers
Writing XML
Output Streams, Writers, and Encodings
A Simple XML-RPC Client
A Simple SOAP Client
Servlets
Summary

Chapter 4. Converting Flat Files to XML
The Budget
The Model
Input
Determining the Output Format
Building Hierarchical Structures from Flat Data
Alternatives to Java
Relational Databases
Summary

Chapter 5. Reading XML
InputStreams and Readers
XML Parsers
SAX
DOM
JAXP
JDOM
dom4j
ElectricXML
XMLPULL
Summary


Part II. SAX
Chapter 6. SAX
What Is SAX?
Parsing
Callback Interfaces
Receiving Documents
Receiving Elements
Handling Attributes
Receiving Characters
Receiving Processing Instructions
Receiving Namespace Mappings
"Ignorable White Space"
Receiving Skipped Entities
Receiving Locators
What the ContentHandler Doesn't Tell You
Summary

Chapter 7. The XMLReader Interface
Building Parser Objects
Input
Exceptions and Errors
Features and Properties
DTDHandler
Summary

Chapter 8. SAX Filters
The Filter Architecture
The XMLFilter Interface
Content Filters
The XMLFilterImpl Class
Parsing Non-XML Documents
Multihandler Adapters
Summary

Part III. DOM
Chapter 9. The Document Object Model
The Evolution of DOM
DOM Modules
Application-Specific DOMs
Trees
DOM Parsers for Java
Parsing Documents with a DOM Parser
The Node Interface
The NodeList Interface
JAXP Serialization
DOMException
Choosing between SAX and DOM
Summary

Chapter 10. Creating XML Documents with DOM
DOMImplementation
Locating a DOMImplementation
The Document Interface as an Abstract Factory
The Document Interface as a Node Type
Normalization
Summary
Chapter 11. The DOM Core
The Element Interface
The NamedNodeMap Interface
The CharacterData Interface
The Text Interface
The CDATASection Interface
The EntityReference Interface
The Attr Interface
The ProcessingInstruction Interface
The Comment Interface
The DocumentType Interface
The Entity Interface
The Notation Interface
Summary

Chapter 12. The DOM Traversal Module
NodeIterator
NodeFilter
TreeWalker
Summary

Chapter 13. Output from DOM
Xerces Serialization
OutputFormat
DOM Level 3
Summary
Part IV. JDOM
Chapter 14. JDOM
What Is JDOM?
Creating XML Elements with JDOM
Creating XML Documents with JDOM
Writing XML Documents with JDOM
Document Type Declarations
Namespaces
Reading XML Documents with JDOM
Navigating JDOM Trees
Talking to DOM Programs
Talking to SAX Programs
Java Integration
What JDOM Doesn't Do

Chapter 15. The JDOM Model
The Document Class
The Element Class
The Attribute Class
The Text Class
The CDATA Class
The ProcessingInstruction Class
The Comment Class
Namespaces
The DocType Class
The EntityRef Class


Part V. XPath/XSLT
Chapter 16. XPath
Queries
The XPath Data Model
Location Paths
Expressions
XPath Engines
DOM Level 3 XPath
Jaxen

Chapter 17. XSLT
XSL Transformations
TrAX
Extending XSLT with Java

Part VI. Appendixes
Appendix A. XML API Quick Reference
SAX
DOM
JAXP
TrAX
JDOM
XMLPULL

Appendix B. SOAP 1.1 Schemas
The SOAP 1.1 Envelope Schema
The SOAP 1.1 Encoding Schema
W3C Software Notice and License


Download This Books......

Apr 22, 2008

Java EE and .Net Interoperability: Integration Strategies, Patterns, and Best Practices


Structure of the Book:


This book covers two main constituents of any Java EE.NET integration. The first one pertains to the integration type such as synchronous or asynchronous, outlining how individual Java and .NET components can integrate using their diverse technology set. The second constituent relates to the quality of service requirements, such as security, reliability, and scalability, essential to meet a Service Level Agreement (SLA) across the heterogeneous enterprise environment. If you take a closer look at the book structure, you'll notice that the book represents a catalog of integration strategies that adheres to the following format:
  • Strategy Name The strategy has a unique name that reflects its objective.
  • Problem space Each strategy aims to address a specific Java EE.NET interoperability problem. Asynchronous reliable integration is an example of such a problem.
  • Solution This part of the strategy details a strategy design and outlines technology choices.
  • Benefits and Limitations Any interoperability strategy has its pros and cons that are highlighted here. For example, ease of maintenance or scalability are common benefits of some of the strategies.
  • Related Patterns Industry patterns such as Core J2EE Patterns are used throughout this book to bring those that are familiar to you into the scope of Java EE.NET integration. Are there similar resources in the .NET space?
  • Example Throughout the book, use cases from the WS-I Supply Chain Management Application (SCMA) are utilized to demonstrate how to implement a strategy. Most of the strategies have two sets of samples corresponding to the Java.NET and .NETJava communication.
The strategy catalog comprises the core of this book and can be used as a reference manual on Java EE.NET interoperability. Before delving into the strategy discussion, it is helpful to review the fundamentals of the Java EE and .NET platforms. The emphasis in reviewing these platforms will focus on their interoperability characteristics. Both platforms expose APIs to develop component-based, loosely coupled integration points. The platform overview is followed by Part II, "Synchronous Integration Solutions," which discusses common business scenarios and reasons for synchronous integration. The de facto technology to integrate disparate applications is based on Web services. Chapter 4, "Web Services for Synchronous Integration," demonstrates how a .NET application can discover and access a Web service implemented in Java and vice versa. The synchronous integration discussion continues with the .NET Remoting technology that remains an alternative to Web services and is adopted by open source and various commercial solutions. The .NET Remoting is shipped as part of the Microsoft Indigo Services. Chapter 6, "Resource Tier Synchronous Integration," details database and legacy integration. It demonstrates a simple strategy to build a Data Access Layer to connect to heterogeneous RDMSs, such as MySql and SQL Server. All in all, synchronous integration strategies are useful if you have two systems with tight coupling or strong dependencies. The industry, however, is heavily leaning toward asynchronous application integration.

Asynchronous integrations between Java EE and .NET systems are easier to maintain, less brittle, and tend to be more scalable. Therefore, the majority of the strategies in this book fall under Part III, "Asynchronous Integration Solutions." The first two strategies, Automatic Callback and Response Polling, are based on Web services technologies. They fundamentally differ from the approach taken in the previous section. The main goal of these strategies is to factor out remote calls from the rest of the request processing. The response can be sent via the callback or polling technique. Chapter 9, "Messaging," unveils five distinct strategies that help to automate and streamline the Java EE and .NET system integration around MOM, SMTP, and Enterprise Service Bus technologies. Reliable message delivery is the key differentiator of these strategies. Similar to the previous section, Chapter 10, "Resource Tier Asynchronous Integration," shows how to asynchronously communicate with back-end resources.

Part IV of the book addresses "Quality of Services" for interoperability. It incorporates several chapters that discuss how to implement a secure, reliable, interoperable Java EE.NET environment. This section encompasses distributed transactions and management of a heterogeneous environment, but most importantly it provides best practices on the enterprise architecture that mitigates security, manageability, availability, and reliability risks. The table here outlines strategies listed in this catalog.

Aside from the integration and systemic quality strategies, this book discusses how to deploy a .NET application under a Java EE application server and how to manually port a .NET application to Java. These strategies are included in Chapter 16, "Migrating .NET Applications to Java." Each chapter of this book intends to give the reader an overview of the technologies and concepts used by individual strategies. Messaging, resource pooling, threading, and asynchronous programming models differ under the Java EE and .NET platforms. Understanding these programming models under each platform enables the reader to effectively apply strategy within a specific domain.

Download This Books

THE Java™ EE 5 Tutorial


About This Tutorial:

THE Java™ EE 5 Tutorial is a guide to developing enterprise applications for the Java Platform, Enterprise Edition 5 (Java EE 5). Here we cover all the things you need to know to make the best use of this tutorial.

Who Should Use This Tutorial:

This tutorial is intended for programmers who are interested in developing and deploying Java EE 5 applications on the Sun Java System Application Server Platform Edition 9.

How to Read This Tutorial

The Java EE 5 platform is quite large, and this tutorial reflects this. However, you don’t have to digest everything in it at once. The tutorial has been divided into parts to help you navigate the content more easily.
This tutorial opens with an introductory chapter, which you should read before proceeding to any specific technology area. Chapter 1 covers the Java EE 5 platform architecture and APIs along with the Sun Java System Application Server Platform Edition 9.
When you have digested the basics, you can delve into one or more of the five main technology areas listed next. Because there are dependencies between some of the chapters, Figure 1 contains a roadmap for navigating through the tutorial.

The web-tier technology chapters cover the components used in developing the presentation layer of a Java EE 5 or stand-alone web application:
• Java Servlet • JavaServer Pages (JSP) • JavaServer Pages Standard Tag Library (JSTL) • JavaServer Faces • Web application internationalization and localization

The web services technology chapters cover the APIs used in developing

standard web services:
• The Java API for XML-based Web Services (JAX-WS) • The Java API for XML Binding (JAXB) • The Streaming API for XML (StAX) • The SOAP with Attachments API for Java (SAAJ) • The Java API for XML Registries (JAXR)

The Enterprise JavaBeans (EJB) technology chapters cover the components

used in developing the business logic of a Java EE 5 application:
• Session beans
• Message-driven beans

The Persistence technology chapters cover the Java Persistence API, which

is used for accessing databases from Java EE applications:
• Introduction to the Java Persistence API
• Persistence in the Web Tier
• Persistence in the EJB Tier
• The Java Persistence Query Language

The platform services chapters cover the system services used by all the

Java EE 5 component technologies:
• Transactions
• Resource connections
• Security
• Java Message Service
• The Connector architecture

After you have become familiar with some of the technology areas, you are
ready to tackle the case studies, which tie together several of the technologies discussed in the tutorial. The Coffee Break Application (Chapter 37) describes an application that uses the web application and web services APIs. The Duke’s Bank Application (Chapter 38) describes an application that employs web application technologies, enterprise beans, and the Java Persistence API.

Finally, the appendix contains auxiliary information helpful to the Java EE 5
application developer:
• Java encoding schemes (Appendix A)

Download The Java EE 5 Tutorial


Rapid J2EE Development: An Adaptive Foundation for Enterprise Applications


How This Book Is Organized:
The contents of this book are broken up into four logical parts:

Part I: Adaptive Processes
  • Chapter 1: A J2EE Tutorial Adaptive Foundation. This chapter introduces the concepts behind the creation of an adaptive foundation for rapid development.
  • Chapter 2: Rapid Application Development. Techniques commonly associated with the rapid development of software, including rapid development languages, approaches to prototyping, and timeboxed development methods, are described in this chapter.
  • Chapter 3: Embracing Adaptive Methods. Chapter 3 explores the importance of lightweight development methodologies that incorporate an iterative approach to building software.
Part II: Agile Architectures
  • Chapter 4: Designing for Rapidity. This chapter looks at how the choices we make at design time have implications for the project's timeframe.
  • Chapter 5: Modeling Software. The topic of this chapter is the use of models for building software architectures, and it examines how UML diagrams enable the communication, validation, and exploration of system designs.
  • Chapter 6: Code Generation. We discuss the merits of passive and active code generation. The use of XDoclet for generating boilerplate code artifacts for Enterprise JavaBeans is illustrated by example, along with the use of Apache's Velocity template engine.
  • Chapter 7: Rapidity and the Database. The repetitive nature of data access code makes it a prime candidate for code generation. This chapter looks at the time savings to be had from the use of the code generation tool Middlegen, as well as at how object-relational mapping products can ease the process of mixing object-oriented technology with that of relational database technology.
  • Chapter 8: Model-Driven Architecture. This chapter brings together models with code generation techniques to explore the MDA paradigm. The use of the open source MDA tool AndroMDA is covered by example.

Part III: Rapid Languages

  • Chapter 9: Scripting. This chapter looks at the benefits of scripting languages and introduces the Java-compatible scripting language Jython.
  • Chapter 10: Working to Rule. This chapter examines the benefits of using rule engines to maintain business logic. The open source, expert system shell Jess is introduced as an example of a rule-based language.
  • Chapter 11: Aspect-Oriented Programming. AOP provides new language constructs for modularizing crosscutting concerns. The result is a powerful mechanism for applying changes dynamically to an application. This chapter introduces the AOP language AspectJ and the AOP framework AspectWerkz.

Part IV: Dynamic Environments

  • Chapter 12: Optimal Builds. Chapter 12 addresses the importance of having a highly efficient and optimized build process in place for conducting rapid development.
  • Chapter 13: The Integrated Development Environment. We examine the need to invest in sophisticated and integrated development tools. The open source developer's workbench Eclipse is introduced as an example of a suitable J2EE development environment.
  • Chapter 14: Test-Driven Development. The practice of test-driven development is key to defining an approach that is resilient to changing requirements and designs. This chapter looks at the importance of constructing an automated unit test suite and covers the JUnit framework for writing unit tests as well as the use of mock objects in testing.
  • Chapter 15: Efficient Quality Assurance. The final chapter looks at using automated testing tools for undertaking functional and performance testing. The open source tools HttpUnit and Apache JMeter are covered by example.

Download This Books

Apr 21, 2008

The Java 2 Platform, Enterprise Edition (J2EE)

Overview of the Book and Technology:

The Java 2 Platform, Enterprise Edition (J2EE) defines the standard for developing n-tier enterprise applications using Java. J2EE simplifies enterprise applications by basing them on standardized modular components and providing for those components a complete set of services that handle the complexities automatically.

N-tier applications are difficult to build. Usually building such an application
requires people with a variety of skills and an understanding of both modern and legacy code and data. Enterprise applications typically use heterogeneous approaches to systems development and require the integration of tools from a variety of vendors and the merging of disparate application models and standards.



This book covers the various components of J2EE that are used to build enterprise
n-tier applications, including the following:
  • JavaServer Pages (JSP)
  • Enterprise JavaBeans (EJB)
  • Java Messaging Service (JMS)
  • Java Naming and Directory Interface (JNDI)
  • Java Authentication and Authorization Service (JAAS)
  • Java Connector Architecture (JCA)
  • And more . . .

The author team recommends that the chapters in this book be read in order, as each chapter builds upon previous chapters. If reading the chapters in order is not viable, reading a particular section in a single sitting may be a better choice.

Contents :
Part I: Introduction
Chapter 1: Understanding Java and the J2EE Platform
Chapter 2: Reviewing XML Fundamentals
Chapter 3: Introducing Application Servers
Chapter 4: Understanding Remote Method Invocation

Part II: The Presentation Tier
Chapter 5: Studying Servlet Programming
Chapter 6: Going Over JSP Basics
Chapter 7: Using JSP Tag Extensions

Part III: The Enterprise Information System Tier
Chapter 8: Working with JavaMail
Chapter 9: Understanding the Java Messaging Service
Chapter 10: Introducing Java Transactions
Chapter 11: Examining JNDI and Directory Services
Chapter 12: Understanding Java Authentication and Authorization Services
Chapter 13: Exploring Java Cryptography Extensions

Part IV: The Service Tier
Chapter 14: Understanding EJB Architecture and Design
Chapter 15: Explaining Session Beans and Business Logic .
Chapter 16: Working with Entity Beans
Chapter 17: Using Message-Driven Beans

Part V: The Data Tier
Chapter 18: Reviewing Java Database Connectivity
Chapter 19: Understanding the J2EE Connector Architecture

Part VI: Web Services
Chapter 20: Introducing Web Services
Chapter 21: Digging Deeper into SOAP, WSDL, and UDDI
Chapter 22: Understanding J2EE Web Services

Part VII: Patterns
Chapter 23: Reviewing Presentation-Tier Patterns
Chapter 24: Working with Service-Tier Patterns
Chapter 25: Using Data-Tier Patterns

Part VIII: Advanced Topics
Chapter 26: Exploring Frameworks and Application Architecture
Chapter 27: Using ANT to Build and Deploy Applications
Chapter 28: Creating High-Performance Java Applications
Appendix A: Airline Reservations Business Case
Appendix B: Magazine Publisher Business Case
Appendix C: Additional Reading and References

Download This Books and tutorials

The Java™ EE 5 Tutorial, Third Edition: For Sun Java System Application Server Platform Edition 9

This tutorial is a guide to developing enterprise applications for the Java Platform, Enterprise Edition 5 (Java EE 5). Here we cover all the things you need to know to make the best use of this tutorial.

Who Should Use This Tutorial :
This tutorial is intended for programmers who are interested in developing and deploying Java EE 5 applications on the Sun Java System Application Server Platform Edition 9.

How to Read This Tutorial
The Java EE 5 platform is quite large, and this tutorial reflects this. However, you don't have to digest everything in it at once. The tutorial has been divided into parts to help you navigate the content more easily.

This tutorial opens with an introductory chapter, which you should read before proceeding to any specific technology area. Chapter 1 covers the Java EE 5 platform architecture and APIs along with the Sun Java System Application Server Platform Edition 9.
When you have digested the basics, you can delve into one or more of the five main technology areas listed next. Because there are dependencies between some of the chapters, Figure 1 contains a roadmap for navigating through the tutorial.

The web-tier technology chapters cover the components used in developing the presentation layer of a Java EE 5 or stand-alone web application:
  • Java Servlet
  • JavaServer Pages (JSP)
  • JavaServer Pages Standard Tag Library (JSTL)
  • JavaServer Faces
  • Web application internationalization and localization
The web services technology chapters cover the APIs used in developing standard web services:
  • The Java API for XML-based Web Services (JAX-WS)
  • The Java API for XML Binding (JAXB)
  • The Streaming API for XML (StAX)
  • The SOAP with Attachments API for Java (SAAJ)
  • The Java API for XML Registries (JAXR)

The Enterprise JavaBeans (EJB) technology chapters cover the components used in developing the business logic of a Java EE 5 application:
  • Session beans
  • Message-driven beans

The Persistence technology chapters cover the Java Persistence API, which is used for accessing databases from Java EE applications:
  • Introduction to the Java Persistence API
  • Persistence in the Web Tier
  • Persistence in the EJB Tier
  • The Java Persistence Query Language

The platform services chapters cover the system services used by all the Java EE 5 component technologies:
  • Transactions
  • Resource connections
  • Security
  • Java Message Service
  • The Connector architecture

Download this tutorial

Apr 20, 2008

JSP Tutorial



This is a tutorial to help a developer understand what is meant by JavaServer Pages (JSP). The reader will learn the main concepts, setup the JSP environment on their computer and write a few JSP programs.

JavaServer Pages (JSP) is a technology based on the Java language and enables the development of dynamic web sites. JSP was developed by Sun Microsystems to allow server side development. JSP files are HTML files with special Tags containing Java source code that provide the dynamic content. The following shows the Typical Web server, different clients connecting via the Internet to a Web server. In this example, the Web server is running on Unix and is the very popular Apache Web server.

First static web pages were displayed. Typically these were people’s first experience with making web pages so consisted of My Home Page sites and company marketing information. Afterwards Perl and C were languages used on the web server to provide dynamic content. Soon most languages including Visualbasic, Delphi, C++ and Java could be used to write applications that provided dynamic content using data from text files or database requests. These were known as CGI server side applications. ASP was developed by Microsoft to allow HTML developers to easily provide dynamic content supported as standard by Microsoft’s free Web Server, Internet Information Server (IIS). JSP is the equivalent from Sun Microsystems, a comparison of ASP and JSP will be presented in the following section.

Why use JSP?
JSP is easy to learn and allows developers to quickly produce web sites and applications in an open and standard way. JSP is based on Java, an object- oriented language. JSP offers a robust platform for web development.

Main reasons to use JSP:

1. Multi platform
2. Component reuse by using Javabeans and EJB.
3. Advantages of Java.
You can take one JSP file and move it to another platform, web server or JSP Servlet engine.

Download

JavaServer Pages (JSP) Tutorials


This is a tutorial to help a developer understand what is meant by JavaServer Pages (JSP). The reader will learn the main concepts, setup the JSP environment on their computer and write a few JSP programs.

JavaServer Pages (JSP) is a technology based on the Java language and enables the development of dynamic web sites. JSP was developed by Sun Microsystems to allow server side development. JSP files are HTML files with special Tags containing Java source code that provide the dynamic content. The following shows the Typical Web server, different clients connecting via the Internet to a Web server. In this example, the Web server is running on Unix and is the very popular Apache Web server.

First static web pages were displayed. Typically these were people’s first experience with making web pages so consisted of My Home Page sites and company marketing information. Afterwards Perl and C were languages used on the web server to provide dynamic content. Soon most languages including Visualbasic, Delphi, C++ and Java could be used to write applications that provided dynamic content using data from text files or database requests. These were known as CGI server side applications. ASP was developed by Microsoft to allow HTML developers to easily provide dynamic content supported as standard by Microsoft’s free Web Server, Internet Information Server (IIS). JSP is the equivalent from Sun Microsystems, a comparison of ASP and JSP will be presented in the following section.

Why use JSP?
JSP is easy to learn and allows developers to quickly produce web sites and applications in an open and standard way. JSP is based on Java, an object- oriented language. JSP offers a robust platform for web development.
Main reasons to use JSP:
1. Multi platform
2. Component reuse by using Javabeans and EJB.
3. Advantages of Java.
You can take one JSP file and move it to another platform, web server or JSP Servlet engine

Download


Java Programming for Wireless devices using Java 2 Platform Micro Edition (J2ME)


What is a J2ME Configuration?

A configuration defines the minimum Java™ technology that can be expected to be available on implementing devices Broad range of devices Similar requirements for memory size and processing capabilities Configurations are specified via the Java Community Process Implementations are tested via a compatibility test kit (TCK)

J2ME Configurations
J2ME Connected, Limited Device Configuration (CLDC) Specifies Java environment for mobile phone, pager, and PDA class devices CLDC devices are usually wireless J2ME Connected Device Configuration (CDC) Specifies Java environment for digital television settop boxes, high end wireless devices, and automotive telematics systems. CDC devices may be wired (DTV cable, etc.)

What Is a J2ME Profile?
Java™ technology which supplements a Configuration to provide capabilities for a specific vertical market or device type Defined through Java Community Process initiative Subject to compatibility tests

J2ME Profiles
  • Mobile Information Device Profile (MIDP)
  • Profile for wireless devices implementing CLDC
  • J2ME Foundation Profile
  • Profile for non-GUI networked devices implementing
  • CDC
  • J2ME Personal Basis, Personal, RMI Profiles
  • Basic graphics, next generation PersonalJava environment, and RMI support for CDC &
  • Foundation Profile based devices
Download

MIDlet development with J2ME and MIDP


Why J2ME?
Nokia, the dominant player in the mobile phone market, has estimated that in 2002 it will sell over 50 million J2ME-enabled mobile phones. With lofty numbers announced by other mobile phone manufacturers as well, there is a flood of interest in software development revolving around J2ME (Java 2 Micro Edition). J2ME is a slimmed-down version of Java targeted at devices that have limited memory, display, and processing power.

This tutorial provides a step-by-step introduction to downloading, installing, and
configuring your computer to begin development of applications for this runtime environment. There will be a specific focus on application development for mobile devices using an application programming interface (API) known as the Mobile Information Device Profile (MIDP). Applications written for this API are affectionately referred to as MIDlets.

Download MIDlet development with J2ME and MIDP

Apr 19, 2008

XML programming in Java technology, Part 2

In an earlier tutorial ("XML programming in Java technology, Part 1"), I showed you the basics of XML parsing in the Java language. I covered the major APIs (DOM, SAX, and JDOM), and went through a number of examples that demonstrated the basic tasks common to most XML applications. This tutorial will look at more difficult things that weren't covered before, such as:
• Getting and setting parser features
• Working with namespaces
• Validating XML documents

As in the introductory tutorial, the APIs I'll cover are:
• The Document Object Model (DOM), Levels 1, 2, and 3
• The Simple API for XML (SAX), Version 2.0
• JDOM, a simple Java API created by Jason Hunter and Brett McLaughlin
• The Java API for XML Processing (JAXP)

I'll also cover several approaches to validation, including W3C XML Schema, RELAX
NG, and Schematron.

About the examples
Most of the examples here will work with the Shakespearean sonnet that appeared in the last tutorial. The structure of this sonnet is:









[14 elements]




In the various sample programs, some versions of this document will have namespaces, and some will use DTDs, W3C XML Schemas, or other schema languages for validation. For the complete examples, see the following files:
• sonnet.xml
• sonnet.dtd (download to view in a text editor)
sonnetNamespaces.xml
sonnet.xsd
sonnetSchema.xml
sonnet.rng
sonnetRules.xsl
sonnetSchematron.xml
As an alternative, download x-java2_code_files.zip to view these files in a text editor.

Download this tutorial

XML programming in Java technology, Part 1

About this tutorial

Over the last few years, XML has become a universal data format. In this updated tutorial, I'll show you the most common programming interfaces for working with XML documents in the Java language. The most common XML processing task is parsing an XML document. Parsing involves reading an XML document to determine its structure and contents. One of the pleasures of XML programming is the availability of open-source, no-cost XML parsers that read XML documents for you. This tutorial focuses on creating parser objects, asking those parsers to process XML files, and handling the results. As you might expect, you can do these common tasks in several different ways; I'll examine the standards involved as well as when you should use one approach or another.

Programming interfaces
A number of programming interfaces have been created to simplify writing Java programs that process XML. These interfaces have been defined by companies, by standards bodies, and by user groups to meet the needs of XML programmers. In this tutorial, I'll cover the following interfaces:
• The Document Object Model (DOM), Level 2
• The Simple API for XML (SAX), Version 2.0
• JDOM, a simple Java API created by Jason Hunter and Brett McLaughlin
• The Java API for XML Processing (JAXP)

The first three of these four interfaces (DOM, SAX, and JDOM) define how the
contents of an XML document are accessed and represented. JAXP contains classes for creating parser objects. To create DOM or SAX parsers, you'll use JAXP. When you use JDOM, the JDOM library uses JAXP under the covers to create a parser. To sum it all up:
• You use DOM, SAX, or JDOM to work with the contents of an XML document.
• If you use DOM or SAX, you use JAXP to create a parser.
• If you use JDOM, the JDOM library creates a parser for you.

I'll explore the design goals, strengths, and weaknesses of each of these APIs, along
with a bit of their histories and the standards bodies that created them.

Download this tutorial

XQuery Java API (tutorial)

This API provides the methods for compiling and executing XQuery/XPath scripts from Java and exploiting the results. This is very similar to using the SQL language through a Java interface like JDBC.
Using XQuest's implementation of XQuery provides a high-level query language and extended processing capabilities. It is therefore advisable to implement the largest possible part of an application with XQuery, and use Java only for retrieving final results. This is especially true when connecting to a remote server, because such an approach will likely minimize the network traffic.
The API is actually used in the GUI and Command-line Interface applications provided with XQuest, as well as in the "Server Pages" extension, which embeds the XQuery engine in a Servlet.

The API allows:
• Creation and setup of a compilation and execution environment (which implements both the static context and dynamic context defined in the XQuery Specifications). These environments are basically provided by an interface named XQueryConnection Creation of Expressions from a XQueryConnection (interfaces XQueryExpression and XQueryPreparedExpression ). Such expressions are similar to Statements found in database connectivity interfaces like JDBC. Expressions receive a Query (i.e. a XQuery script) which is compiled and then executed once or several times.

An Expression is itself a context which inherits the environment provided by the connection, and can then be set up individually before execution. In particular, it is possible to bind global variables of the XQuery expressions to initial values.

• Exploitation of results of Expression evaluations.

The result sets are iterators, since the XQuery/XPath2 language can generally return se- quences of Items. Items are either atomic values (such as numbers or strings), or Nodes, which describe the structure of XML documents and data. The properties and relationships of Nodes are de- scribed in a section of the XQuery/XPath2/XSLT2 specifications which is called the Data Model. A section of the present document is dedicated to the Data Model interfaces, which handle Nodes.

For calling Java methods from within XQuery expressions, see the Java Binding section of the XQuery Extensions documentation.
For dealing specifically with XML databases (XML Libraries), see the XML Library API


Download

Troubleshooting Guide for Java

This document helps in troubleshooting problems that might occur with applications that use the desktop technologies in the SunMicrosystems Inc. release of JavaTM Platform, Standard EditionDevelopment Kit 6 (JDKTM 6 release or Java SE 6 release). Most of the information in this guide also applies to the Java SE 5 release (also known as Java 2 SE 1.5 or 5.0). Information that applies only to Java SE 6 is indicated accordingly. For help in troubleshooting possible problems between the application and the JavaHotSpotTM virtual machine, see the Troubleshooting Guide for Java SE 6 withHotSpotVMor the Java 2 SE 5.0 Troubleshooting and Diagnostic Guide.

Who ShouldUseThis Guide
The target audience for this document comprises developers who are working with the desktop technologies in Java SE 5 or 6, as well as support or administration personnel who maintain applications that are deployed with Java SE 5 or 6. This document is intended for readers with a detailed understanding of the desktop technologies, a high-level understanding of the components of the Java VirtualMachine, as well as some understanding of concepts such as garbage collection, threads, native libraries, and so on. In addition, it is assumed that the reader is reasonably proficient on the operating system where the Java SE application is installed.

HowThis Guide Is Organized
The first chapter of this guide introduces the desktop technologies, presents some general troubleshooting information and guidelines, and introduces some troubleshooting tools. Further chapters suggest procedures to try when you encounter problems with some of the desktop technologies, namely, AWT, Java 2D, Swing, Internationalization, Java Sound, and Java Plug-in.More desktop technologies will be gradually added to this guide. The last chapter provides suggestions on what to try before submitting a bug report, guidance on how to submit a report, and suggestions on what data to collect for the report. Finally, there is an appendix for each of the following reference areas: Java 2D properties, and details about the format of the fatal error report.


Download

Apr 17, 2008

XML - Application Programming Interfaces (APIs)

Overview Java XML API

The most important decision you'll make at the start of an XML project is the application- programming interface (API) you'll use. Many APIs are implemented by multiple vendors, so if the specific parser gives you trouble you can swap in an alternative, often without even recompiling your code. However, if you choose the wrong API, changing to a different one may well involve redesigning and rebuilding the entire application from scratch. Of course, as Fred Brooks taught us, “In most projects, the first system built is barely usable. It may be too slow, too big, awkward to use, or all three. There is no alternative but to start again, smarting but smarter, and build a redesigned version in which these problems are solved.… Hence plan to throw one away; you will, anyhow. ” [1] Still, it is much easier to change parsers than APIs.

There are two major standard APIs for processing XML documents with Java, the Simple API for XML (SAX) and the Document Object Model (DOM), each of which comes in several versions. In addition there are a host of other, somewhat idiosyncratic APIs including JDOM, dom4j, ElectricXML, and XMLPULL. Finally each specific parser generally has a native API that it exposes below the level of the standard APIs. For instance, the Xerces parser has the Xerces Native Interface (XNI). However, picking such an API limits your choice of parser, and indeed may even tie you to one particular version of the parser since parser vendors tend not to worry a great deal about maintaining native compatibility between releases. Each of these APIs has its own strengths and weaknesses.

SAX
SAX, the Simple API for XML, is the gold standard of XML APIs. It is the most complete and correct by far. Given a fully validating parser that supports all its optional features, there is very little you can’t do with it. It has one or two holes, but they're really off in the weeds of the XML specifications, and you have to look pretty hard to find them. SAX is a event driven API. The SAX classes and interfaces model the parser, the stream from which the document is read, and the client application receiving data from the parser. However, no class models the XML document itself. Instead the parser feeds content to the client application through a callback interface, much like the ones used in Swing and the AWT.
This makes SAX very fast and very memory efficient (since it doesn’t have to store the entire document in memory). However, SAX programs can be harder to design and code because you normally need to develop your own data structures to hold the content from the document. SAX works best when your processing is fairly local; that is, when all the information you need to use is close together in the document. For example, you might process one element at a time. Applications that require access to the entire document at once in order to take useful action would be better served by one of the tree-based APIs like DOM or JDOM. Finally, because SAX is so efficient, it’s the only real choice for truly huge XML documents. Of course, “truly huge” has to be defined relative to available memory. However, if the documents you're processing are in the gigabyte range, you really have no choice but to use SAX.

DOM
DOM, the Document Object Model, is a fairly complex API that models an XML document as a tree. Unlike SAX, DOM is a read-write API. It can both parse existing XML documents and create new ones. Each XML document is represented as Document object. Documents are searched, queried, and updated by invoking methods on this Document object and the objects it contains. This makes DOM much more convenient when random access to widely separated parts of the original document is required. However, it is quite memory intensive compared to SAX, and not nearly as well suited to streaming applications.

JAXP
JAXP, the Java API for XML Processing, bundles SAX and DOM together along with some factory classes and the TrAX XSLT API. (TrAX is not a general purpose XML API like SAX and DOM. I'll get to it in Chapter 17.) It is a standard part of Java 1.4 and later. However, it is not really a different API. When starting a new program, you ask yourself whether you should choose SAX or DOM. You don’t ask yourself whether you should use SAX or JAXP, or DOM or JAXP. SAX and DOM are part of JAXP.

JDOM
JDOM is a Java-native tree-based API that attempts to remove a lot of DOM’s ugliness. The JDOM mission statement is, “There is no compelling reason for a Java API to manipulate XML to be complex, tricky, unintuitive, or a pain in the neck,” and for the most part JDOM delivers. Like DOM, JDOM reads the entire document into memory before it begins to work on it; and the broad outline of JDOM programs tends to be the same as for DOM programs. However, the low-level code is a lot less tricky and ugly than the DOM equivalent. JDOM uses concrete classes and constructors rather than interfaces and factory methods. It uses standard Java coding conventions, methods, and classes throughout. JDOM programs often flow a lot more naturally than the equivalent DOM program. I think JDOM often does make the easy problems easier; but in my experience JDOM also makes the hard problems harder. Its design shows a very solid understanding of Java, but the XML side of the equation feels much rougher. It’s missing some crucial pieces like a common node interface or superclass for navigation. JDOM works well (and much better than DOM) on fairly simple documents with no recursion, limited mixed content, and a well-known vocabulary. It begins to show some weakness when asked to process arbitrary XML. When I need to write programs that operate on any XML document, I tend to find DOM simpler despite its ugliness.

Download XML - Application Programming Interfaces (APIs)

Apr 15, 2008

java xml soap: Processing XML with Java


Processing XML with Java™: A Guide to SAX, DOM Java, JDOM, JAXP, and TrAX, java xml database. This book and tutorial is written for experienced Java developers who want to integrate XML into their systems. Java is the ideal language for processing XML documents. Its strong Unicode support in particular made it the preferred language for many early implementers. Consequently, more XML tools have been written in Java than in any other language. More open source XML tools are written in Java than in any other language. More developers process XML in Java than in any other language.

Processing XML with Java™ will teach you how to
Save XML documents from applications written in Java
Read XML documents produced by other programs
Search, query, and update XML documents
Convert legacy flat data into hierarchical XML
Communicate with network servers that send and receive XML data
Validate documents against DTDs, schemas, and business rules
Combine functional XSLT transforms with traditional imperative Java code


Processing XML with Java™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX is intended for Java developers who need to do anything with XML. It teaches the fundamentals and advanced topics, leaving nothing out. It is a comprehensive course in processing XML with Java that takes developers from having little knowledge of XML to designing sophisticated XML applications and parsing complicated documents. The examples cover a wide range of possible uses, including file formats, data exchange, document transformation, database integration, and more.

Praise for Elliotte Rusty Harold's Processing XML for Java
List of Examples
List of Figures
Preface
Who You Are
How to Use This Book
The Online Edition
Some Grammatical Notes
Contacting the Author
Acknowledgments

Part I. XML
Chapter 1. XML for Data
Motivating XML
XML Syntax
Validity
Stylesheets
Summary

Chapter 2. XML Protocols: XML-RPC and SOAP
XML as a Message Format
HTTP as a Transport Protocol
RSS
Customizing the Request
XML-RPC SOAP
Custom Protocols
Summary

Chapter 3. Writing XML with Java
Fibonacci Numbers
Writing XML
Output Streams, Writers, and Encodings
A Simple XML-RPC Client
A Simple SOAP Client
Servlets
Summary

Chapter 4. Converting Flat Files to XML
The Budget
The Model
Input
Determining the Output Format
Building Hierarchical Structures from Flat Data
Alternatives to Java
Relational Databases
Summary

Chapter 5. Reading XML
InputStreams and Readers
XML Parsers
SAX
DOM
JAXP
JDOM
dom4j
ElectricXML
XMLPULL
Summary


Part II. SAX
Chapter 6. SAX
What Is SAX?
Parsing
Callback Interfaces
Receiving Documents
Receiving Elements
Handling Attributes
Receiving Characters
Receiving Processing Instructions
Receiving Namespace Mappings
"Ignorable White Space"
Receiving Skipped Entities
Receiving Locators
What the ContentHandler Doesn't Tell You
Summary

Chapter 7. The XMLReader Interface
Building Parser Objects
Input
Exceptions and Errors
Features and Properties
DTDHandler
Summary

Chapter 8. SAX Filters
The Filter Architecture
The XMLFilter Interface
Content Filters
The XMLFilterImpl Class
Parsing Non-XML Documents
Multihandler Adapters
Summary


Part III. DOM
Chapter 9. The Document Object Model
The Evolution of DOM
DOM Modules
Application-Specific DOMs
Trees
DOM Parsers for Java
Parsing Documents with a DOM Parser
The Node Interface
The NodeList Interface
JAXP Serialization
DOMException
Choosing between SAX and DOM
Summary

Chapter 10. Creating XML Documents with DOM
DOMImplementation
Locating a DOMImplementation
The Document Interface as an Abstract Factory
The Document Interface as a Node Type
Normalization
Summary

Chapter 11. The DOM Core
The Element Interface
The NamedNodeMap Interface
The CharacterData Interface
The Text Interface
The CDATASection Interface
The EntityReference Interface
The Attr Interface
The ProcessingInstruction Interface
The Comment Interface
The DocumentType Interface
The Entity Interface
The Notation Interface
Summary

Chapter 12. The DOM Traversal Module
NodeIterator
NodeFilter
TreeWalker
Summary

Chapter 13. Output from DOM
Xerces Serialization
OutputFormat
DOM Level 3
Summary


Part IV. JDOM
Chapter 14. JDOM
What Is JDOM?
Creating XML Elements with JDOM
Creating XML Documents with JDOM
Writing XML Documents with JDOM
Document Type Declarations
Namespaces
Reading XML Documents with JDOM
Navigating JDOM Trees
Talking to DOM Programs
Talking to SAX Programs
Java Integration
What JDOM Doesn't Do
Summary

Chapter 15. The JDOM Model
The Document Class
The Element Class
The Attribute Class
The Text Class
The CDATA Class
The ProcessingInstruction Class
The Comment Class
Namespaces
The DocType Class
The EntityRef Class
Summary


Part V. XPath/XSLT
Chapter 16. XPath
Queries
The XPath Data Model
Location Paths
Expressions
XPath Engines
DOM Level 3 XPath
Jaxen
Summary

Chapter 17. XSLT
XSL Transformations
TrAX
Extending XSLT with Java
Summary


Part VI. Appendixes
Appendix A. XML API Quick Reference
SAX
DOM
JAXP
TrAX
JDOM
XMLPULL

Appendix B. SOAP 1.1 Schemas
The SOAP 1.1 Envelope Schema
The SOAP 1.1 Encoding Schema
W3C Software Notice and License

Appendix C. Recommended Reading
Books
Specifications

Download java xml soap: Processing XML with Java
Publisher : Addison Wesley
Pub Date : November 08, 2002
ISBN : 0-201-77186-1
Pages : 1120

Apr 9, 2008

J2EE Best Practices: Java Design Patterns, Automation, and Performance


Overview of the Book and Technology
J2EE Best Practices: Java Design Patterns, Automation, and Performance will supply a set of best practices for J2EE software development and then use them to construct an application architecture approach referred to as the reference architecture. The reference architecture will provide a basis for rapidly building transactional business applications using J2EE technology. The design and implementation of the reference architecture is based on a set of guiding principles that will be used to optimize and automate J2EE development.

Contents :
Chapter 1 Building Business Applications with J2EE
Elements of Transactional, Web-Based Business Applications, The Reference Architecture, The J2EE Platform Approach, The Model-View-Controller Architecture Approach, Best Practices for Building Business Applications
with J2EE

Chapter 2 The Business Object Architecture: Design Considerations
Business Objects in a Banking Application, Elements of Business Objects, Design Considerations, Best Practices for Designing Business Objects


Chapter 3 Building Business Objects: Managing Properties and Handling Errors
Managing Properties, Value Objects and Lightweight Business Objects, Object Validation and Error Handling, Best Practices for Implementing Business Objects: Part One


Chapter 4 Building Business Objects: Persistence, Relationships, and the Template Method Pattern
Object Persistence, The Base Class as a Template, Overall Business Object Metadata Approach, Data Caching, Best Practices for Implementing Business Objects: Part Two

Chapter 5 The Service-Based Architecture: Design Considerations
Elements of Service-Based Components, Design Considerations, Best Practices for Designing Service-Based Components

Chapter 6 Building Service-Based Components
The Actual Service Interface, An Implementation for Argument Lists, The Session Bean as a Component Wrapper to the Service, Responsibilities of the Service Component,
Update Service Examples 225
Updating Multiple Business Objects 233
The New Customer Service 234
Data Retrieval Services 240
Building Generic, Reusable Services 251
Implementing the Controller Pattern in Services 253
Best Practices for Implementing Service-Based
Components

Chapter 7 The User Interaction Architecture: Design Considerations and an Overview of Jakarta Struts
Elements of the User Interaction Architecture 261
Design Considerations 265
An Overview of Jakarta Struts 284
Best Practices for Designing the User
Interaction Architecture


Chapter 8 Building the User Interaction Architecture
The Change Address Page 301
The Change Address JSP 307
The View Accounts Page 332
The New Customer Wizard 342
A Template for the Action Class 362
Web Services 369
Best Practices for Implementing the
User Interaction Architecture

Chapter 9 Strengthening the Bank Application: Adding Security and Advanced Functionality
Application Security 375
Interesting Aspects of the Bank Application 392
Best Practices for Advanced Web Application Development 417

Chapter 10 Performance
Overall Performance Approach 421
Performance in J2EE Applications 430
Best Practices for J2EE Performance Engineering

Chapter 11 Moving toward Reuse in the Reference Architecture
Common Roadblocks and Corresponding Best Practices 444
Reuse in the Reference Architecture 452
The Strategic View of the Architecture 454
Best Practices for Moving toward Reuse


Download This Books
Page 496
Copyright © 2003 by Darren Broemmer. All rights reserved.
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
Publisher: Bob Ipsen
Editor: Theresa Hudson
Developmental Editor: Kenyon Brown
Editorial Manager: Kathryn A. Malm
Managing Editor: Pamela Hanley
New Media Editor: Brian Snapp
Text Design & Composition: Interactive Composition Corporation

Apr 8, 2008

Java Server Pages (JSP) Tutorial


Java Server Pages (JSP) is a new technology for web application development that has received a great deal of attention since it was first announced.

Why is Java Server Pages (JSP) so exciting?
One reason is that JSP is Java-based, and Java is well-suited for enterprise computing. In fact, JSP is a key part of the Java™ 2 Enterprise Edition (J2EE) platform and can take advantage of the many Java Enterprise libraries, such as JDBC, JNDI, and Enterprise JavaBeans™. Another reason is that JSP supports a powerful model for developing web applications that separates presentation from processing. Understanding why this is so important requires a bit of a history lesson.

In the early days of the Web, the only tool for developing dynamic web content was the Common Gateway Interface (CGI). CGI outlined how a web server made user input available to a program, as well as how the program provided the web server with dynamically generated content to send back. CGI scripts were typically written in Perl. (In fact, CGI Perl scripts still drive numerous dynamic web sites.) However, CGI is not an efficient solution. For every request, the web server has to create a new operating-system process, load a Perl interpreter and the Perl script, execute the script, and then dispose of the entire process when it's done. To provide a more efficient solution, various alternatives to CGI have been added to programmers' toolboxes over the last few years: FastCGI, for example, runs each CGI program in an external permanent process (or a pool of processes). In addition, mod_perl for Apache, NSAPI for Netscape, and ISAPI for Microsoft's IIS all run server-side programs in the same process as the web server itself. While these solutions offer betterperformance and scalability, each one is supported by only a subset of the popular web servers. The Java Servlet API, introduced in early 1997, provides a solution to the portability issue.

However, all these technologies suffer from a common problem : HTML code embedded inside programs. If you've ever looked at the code for a servlet, you've probably seen endless calls to out.println( ) that contain scores of HTML tags. For the individual developer working on a simple web site this approach may work fine, but it makes it very difficult for people with different skills to work together to develop a web application. This is becoming a significant problem.
As web sites become increasingly complex and are more and more critical to the success of an organization, the appearance and usability of the web interface becomes paramount. New client technologies, such as client-side scripts and DHTML, can develop more responsive and interactive user interfaces, stylesheets can make it easier to globally change fonts and colors, and images can make the interface more appealing.

At the same time, server-side code is getting more complex, and demands for reliability, performance, and fault tolerance are increasing. The growing complexity of web applications requires a development model that allows people with different skills to cooperate efficiently. JavaServer Pages provides just such a development model, allowing web page authors with skills in graphics, layout, and usability to work in tandem with programmers who are experienced in server-side technologies such as multithreading, resource pooling, databases, and caching. While there are other technologies, such as ASP, PHP, and ColdFusion, that support similar development models, none of them offers all the advantages of JSP.

Download Java Server Pages (JSP) Tutorial

Filetype : pdf
Size : 2,328 KB
First Edition, December 2000
Page : 572 pages