E-Book Overview
JavaServer Pages, together with the Java Servlet API, provide the dynamic web content presentation layer for the Java 2 Enterprise Edition. JSPs and Servlets integrate tightly to enable scalable and portable applications, and are widely supported. This book extensively covers the next generation of these technologies, JSP 1.2 and Servlets 2.3, which are nearing completion under the Java Community Process and provide major enhancements to Java's web programming model.
This book looks in depth at these core components of the forthcoming J2EE 1.3 platform, preparing you for building the next generation of web solutions. You'll learn about the enhancements to the JSP tag library model; the new filtering and application event facilities; how to architect web applications to ensure clean separation of presentation and logic; and the increasingly popular Jakarta Struts framework. The book also addresses using JSP with XML and XSLT; databases access with JDBC; and how JSP and Servlets fit into the overall J2EE platform alongside Enterprise JavaBeans, JavaMail, and other J2EE technologies.
E-Book Content
12
JSP and XML XML and JSP are two important tools available in producing a web application. This chapter examines the potential of mixing these two technologies in order to enhance the capabilities of JSP. While this chapter will cover many things about XML, this chapter will not attempt to teach XML. Instead it focuses on how JSP and XML can be used together as a highly flexible and powerful tool. In general the usage of XML in these examples will be kept simple and should cause no problems for users who are starting XML. In short the chapter will be broken down into five main sections: ❑
A quick look at XML Why is XML valuable? Before even dealing with XML combined with JSP we need to understand why it would be beneficial to do so. As mentioned this is not going to be a tutorial on how to write your own XML and XSLT. Instead the first section will be dealing with concepts of XML and its implementation in your project.
❑
An overview of Java-XML tools Using XML with JSP is much easier if you have the right tools. Before diving right in to some examples this section will give a brief overview of some of the most popular JavaXML tools. Along with overviews we will also cover which tools this chapter requires and where to get them.
❑
Focus on the DOM, JDOM and SAX Several pre-built Java based code libraries are available to access XML. This section will go more in depth about dealing with the Document Object Model, Java Document Object Model and Simple API for XML. While DOM, JDOM, and SAX can be of great aid to a developer, the reader should understand the benefits and drawbacks for each API. This section will cover the DOM in the greatest detail as it can be considered to be the baseline standard for working with XML.
Chapter 12
❑
A Step By Step Tutorial The best way to learn is to walk through and build some useful code. This section will show you a practical example on how JSP and XML can be combined to work together on a project. The best part is the code will be reusable for any project. The tutorial will help you create a JSP tag library to use with XML.
❑
JSP Documents A review of the merging of XML and JSP in the JSP 1.2 Specification. All of the examples up to this point are implemented using the JSP 1.1 specifications simply because most developers are already familiar with them. JSP 1.2 shows great promise in allowing JSP to be authored in a fully XML compliant syntax. This section is devoted to understanding the new XML based JSP syntax.
What Is XML? Besides being a common buzzword, what exactly is XML? Before diving right in to the code let's take some time to examine what exactly XML is and what it is good for. For th