Java instantcode developing JSP and XML integrated solutions

517 70 0
Java instantcode developing JSP and XML integrated solutions

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Java InstantCode: Developing JSP and XML Integrated Solutions SkillSoft © 2004 Use this code-intensive reference to learn about developing JSP and XML integrated solutions using XML-based JSP documents, the Java API for XML Processing (JAXP), and JDOM Table of Contents Introduction Copyright Creating Web Applications Using XML-Based Point 1 JSP Documents Creating a JSP Application to Process and Point 2 Transform XML Documents Using JAXP Creating a JSPXML Integrated System Using Point 3 JDOM Generating Dynamic XML Content in JSP Point 4 Applications Developing JSP Custom Tags for Integrating Point 5 and Displaying XML Data Using JavaServer Pages Standard Tag Library Point 6 (JSTL) Tags in JSP XML Applications Creating an Internationalized Application Point 7 Using JSP and XML Index List of Figures List of Examples CD Content Introduction About InstantCode Books The InstantCode series is designed to provide you - the developer - with code you can use for common tasks in the workplace The goal of the InstantCode series is not to provide comprehensive information on specific technologies - this is typically well-covered in other books Instead, the purpose of this series is to provide actual code listings that you can immediately put to use in building applications for your particular requirements How These Books are Structured The underlying philosophy of the InstantCode series is to present code listings that you can download and apply to your own business needs To support this, these books are divided into chapters, each covering an independent task Each chapter includes a brief description of the task, followed by an overview of the element of the book's subject technology that we will use to perform that task Each section ends with a code listing: each of the individual code segments in the chapter is independently downloadable, as is the complete chapter code You will be able to download source code files, as well as application files Who Should Read These Books These books are written for software development professionals who have basic knowledge of the associated technology and want to develop customized technology solutions About the Book This book describes J2EE solutions developed using JavaServer Pages (JSP) and Extensible Markup Language (XML) The book explains developing JSP and XML integrated solutions using XML-based JSP documents, the Java API for XML Processing (JAXP), and JDOM The book also explains how to develop custom tags and use pre existing tag libraries for XML processing in J2EE applications In addition, the book describes how to generate dynamic XML contents from J2EE application and integrate XML to develop internationalized Web applications About the Author Simanta Sarma holds a Bachelor's degree in Engineering and an advanced diploma in Web computing He is proficient in Web, distributed, and enterprise technologies developed in J2EE He has designed and authored numerous books, courseware and articles on J2EE technologies Credits I would like to thank Radhika Chauhan, S Sripriya, and Parag Phukan for helping me complete the book on time I also thank the editors and the quality assurance team for their timely help Copyright Java InstantCode: Developing JSP amd XML Integrated Solutions Copyright © 2004 by SkillSoft Corporation All rights reserved No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of SkillSoft Trademarked names may appear in the InstantCode series Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark Published by SkillSoft Corporation 20 Industrial Park Drive Nashua, NH 03062 (603) 324-3000 information@skillsoft.com The information in this book is distributed on an "as is" basis, without warranty Although every precaution has been taken in the preparation of this work, neither the author nor SkillSoft shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work Point 1: Creating Web Applications Using XMLBased JSP Documents JavaServer Pages (JSP) is a Java 2 Enterprise Edition (J2EE) technology to develop dynamic Web applications In JSP applications, an alternative to relational databases to store application data is eXtensible Markup Language (XML) documents XML documents provide a hierarchical format to store application data using meaningful tags without the overhead of a separate database server To integrate XML in JSP applications, you need to access and store data to and from the XML documents There are several Application Programming Interfaces (APIs), such as Document Object Model (DOM), Simple API for XML (SAX), and JDOM that allow manipulation of XML documents from JSP pages In addition, you can use standard tag libraries, such as Java Standard Tag Library (JSTL) or create your own custom tag library to work with XML documents from JSP pages You can also develop XML-based JSP pages, known as JSP documents to develop Web applications XML-based JSP documents are JSP pages written in XML syntax A JSP document must comply with XML specifications All JSP documents need to have a root tag,, which includes other subtags You save JSP documents as jspx files and deploy them on J2EE application servers Developing XML-based JSP documents allows you to create structured Web pages using XML-based tools JSP documents also enable document validation against an external Document Type Definition (DTD) or schema to ensure consistent document structures This chapter describes how to create a dynamic Web application using XML-based JSP documents The application is an online retail application that allows you to develop JSP documents using XML syntax for JSP declarations, JSP page directives, JSP expressions, and JSP scriptlets Requirements for Online Retail Application The online retail application allows registered end-users to log on to the Web site, view a list of all the items in the store, determine the available quantity and price of each item, and place orders for various items To record the orders placed by an end-user, the application maintains a list of orders sorted by date and time This allows end-users to view order information You can develop the online retail application by integrating the following three modules: Logon module: Authenticates end-users The files in the Logon module are: Logon.jspx: Displays a text field and a password field to obtain information about end-users DoLogon.jspx: Accesses a JavaBean component to authorize an end user to access the retailer's Web site LogonHandler.java: Accesses a back-end database to validate end user information User.java: Represents the end-user's logon information and role An end-user of the Web site can be assigned either the user or the administrator role User module: Allows end-users to view item information, purchase items, and view sales reports of all the items purchased The user module contains the following files: UserPage.jspx: Displays hyperlinks to the other pages of the user module ViewAllItems.jspx: Displays all the available items in the store PurchaseItems.jspx: Displays the user interface that the end user uses to purchase items DoPurchase.jspx: Records information about the purchases made by an end-user ViewTotalPurchase.jspx: Displays all purchases made by an end user Administrator module: Allows the administrator to log on, update item information, record new item information, and view sales records and a list of all the available items in the store The user module contains the following files: AdminPage.jspx: Displays hyperlinks to the other pages of the administrator module ManageItems.jspx: Allows the administrator to add, update, and delete information about items GetAllItems.jspx: Displays the user interface to add, update, and delete information about items AddItem.jspx: Records information about new items added to the store UpdateItem.jspx: Updates information about available items ViewSales.jspx: Displays sale information about all the purchases ViewAllItems.jspx: Displays all the available items of the store Figure 1-1 shows the architecture of the online retail application: Figure 1-1: Architecture of the Online Retail Application Figure 5-18: Searching an Article Figure 5-19: Rating an Article Figure 5-20: User Interface of the DoRateArticle JSP Page Figure 5-21: Displaying Article Ratings Point 6: Using JavaServer Pages Standard Tag Library (JSTL) Tags in JSP XML Applications Figure 6-1: Architecture of the Online News Application Figure 6-2: The MainPage JSP Page Figure 6-3: The MainNewsPage JSP Page Figure 6-4: The NewsDetailPage JSP Page Figure 6-5: The SearchNewsPage JSP Page Figure 6-6: The DoSearchNews JSP Page Figure 6-7: The New Application Dialog Box Figure 6-8: The Edit Contents of WebApp Dialog Box Figure 6-9: The New Web Application Wizard- Component General Properties Dialog Box Figure 6-10: The Deployment Tool Window Figure 6-11: The MainPage JSP Page Figure 6-12: The MainNews JSP Page Figure 6-13: The NewsDetailPage JSP Page Figure 6-14: The SearchNewsPage JSP Page Figure 6-15: The DoSearchNews JSP Page Point 7: Creating an Internationalized Application Using JSP and XML Figure 7-1: Architecture of the Online Discussion Forum Application Figure 7-2: The Home Page Figure 7-3: User Interface of Logon.jsp File for US Figure 7-4: User Interface of Logon.jsp File for France Figure 7-5: User Interface of DoLogon JSP for US on Successful Authentication Figure 7-6: User Interface of DoLogon JSP for France on Unsuccessful Authentication Figure 7-7: User Interface of UserPage JSP in French Figure 7-8: User Interface of AddDiscussion.jsp in French Figure 7-9: User Interface of the ViewDiscussion JSP Page in French Figure 7-10: The New Application Dialog Box Figure 7-11: The Edit Contents of WebApp Dialog Box Figure 7-12: The New Web Application Wizard-Component General Properties Dialog Box Figure 7-13: The Deployment Tool Window Figure 7-14: The Index JSP Page Figure 7-15: The Logon JSP Page Figure 7-16: The DoLogon Page Figure 7-17: The User Options Page Figure 7-18: The Post Message Page Figure 7-19: The View Discussion Page List of Examples Point 1: Creating Web Applications Using XMLBased JSP Documents Listing 1-1: The database.sql File Listing 1-2: The Logon.jspx File Listing 1-3: The DoLogon.jspx File Listing 1-4: The LogonHandler.java File Listing 1-5: The User.java Class Listing 1-6: The UserPage.jspx File Listing 1-7: The ViewAllItems.jspx File Listing 1-8: The PurchaseItems.jspx File Listing 1-9: The DoPurchase.jspx File Listing 1-10: The ViewTotalPurchase.jspx File Listing 1-11: The AdminPage.jspx File Listing 1-12: The ManageItem.jspx File Listing 1-13: The GetAllItems.jspx File Listing 1-14: The AddItem.jspx File Listing 1-15: The UpdateItem.jspx File Listing 1-16: The ViewSales.jspx File Point 2: Creating a JSP Application to Process and Transform XML Documents Using JAXP Listing 2-1: The userlist.xml File Listing 2-2: The musicalbumlist.xml File Listing 2-3: The videoalbumlist.xml File Listing 2-4: The musicpurchaselist.xml File Listing 2-5: The videopurchaselist.xml File Listing 2-6: The Logon.jsp File Listing 2-7: The DoLogon.jsp File Listing 2-8: The AdministratorPage.jsp File Listing 2-9: The AddUser.jsp File Listing 2-10: The DeleteUser.jsp File Listing 2-11: The AddMusicAlbum.jsp File Listing 2-12: The DeleteMusicAlbum.jsp File Listing 2-13: The AddVideoAlbum.jsp File Listing 2-14: The DeleteVideoAlbum.jsp File Listing 2-15: The PurchaseAlbum.jsp File Point 3: Creating a JSPXML Integrated System Using JDOM Listing 3-1: The userlist.xml File Listing 3-2: The directorylist.xml File Listing 3-3: The Logon.jsp File Listing 3-4: The DoLogon.jsp File Listing 3-5: The UserRegistration.jsp File Listing 3-6: The RegisterUser.jsp File Listing 3-7: The AdminPage.jsp File Listing 3-8: The AddEntry.jsp File Listing 3-9: The DoAddEntry.jsp File Listing 3-10: The DeleteEntry.jsp File Listing 3-11: The DoDeleteEntry.jsp File Listing 3-12: The UserPage.jsp File Listing 3-13: The Category.jsp File Listing 3-14: The City.jsp File Listing 3-15: The Zip.jsp File Point 4: Generating Dynamic XML Content in JSP Applications Listing 4-1: The userlist.xml File Listing 4-2: The querylist.xml File Listing 4-3: The Logon.jsp File Listing 4-4: The DoLogon.jsp File Listing 4-5: The DoLogout.jsp File Listing 4-6: The UserPage.jsp File Listing 4-7: The NewQuery.jsp File Listing 4-8: The AdminPage.jsp File Listing 4-9: The QueryReply.jsp File Listing 4-10: The ViewQueryList.jsp File Listing 4-11: The ViewQuery.jsp File Listing 4-12: The QueryXMLGenerator Class Listing 4-13: The technicalhelpdesk.xsl File Point 5: Developing JSP Custom Tags for Integrating and Displaying XML Data Listing 5-1: The userlist.xml File Listing 5-2: The articlelist.xml File Listing 5-3: The technicaldocs-taglib.tld File Listing 5-4: The LoginPage.jsp File Listing 5-5: The DoLogin.jsp File Listing 5-6: The ShowHeaderTag.java File Listing 5-7: The ShowFooterTag.java File Listing 5-8: The ShowloginTag.java File Listing 5-9: The DoLoginTag.java File Listing 5-10: The AdminPage.jsp File Listing 5-11: The UserPage.jsp File Listing 5-12: The FrmSearchTag.java File Listing 5-13: The DoSearchArticle.jsp File Listing 5-14: The ShowArticleTag.java File Listing 5-15: The FormAddArticleTag.java File Listing 5-16: The DoAddArticle.jsp File Listing 5-17: The DoAddArticleTag.java File Listing 5-18: The ModifyDeleteRate.jsp File Listing 5-19: The DoUpdateArticle.jsp File Listing 5-20: The DoUpdateArticleTag.java File Listing 5-21: The DoDeleteArticle.jsp File Listing 5-22: The DoDeleteArticleTag.java File Listing 5-23: The DoRateArticle.jsp File Listing 5-24: The DoRateArticleTag.java File Listing 5-25: The ArticleRatings.jsp File Listing 5-26: The ShowArticleRating.java File Point 6: Using JavaServer Pages Standard Tag Library (JSTL) Tags in JSP XML Applications Listing 6-1: The userlist.xml File Listing 6-2: The newslist.xml File Listing 6-3: The MainPage.jsp File Listing 6-4: The DoLogon.jsp File Listing 6-5: The DoLogout.jsp File Listing 6-6: The MainNewsPage.jsp File Listing 6-7: The NewsDetailsPage.jsp File Listing 6-8: The SearchNewsPage.jsp File Listing 6-9: The DoSearchNews.jsp File Point 7: Creating an Internationalized Application Using JSP and XML Listing 7-1: The userlist.xml File Listing 7-2: The discussionlist.xml File Listing 7-3: The uslist.xml File Listing 7-4: The francelist.xml File Listing 7-5: The LanguageDocParser.java File Listing 7-6: The DisplayString.java File Listing 7-7: The Index.jsp File Listing 7-8: The Logon.jsp File Listing 7-9: The DoLogon.jsp File Listing 7-10: The UserPage.jsp File Listing 7-11: The AddDiscussion.jsp File Listing 7-12: The ViewDiscussion.jsp File CD Content Following are select files from this book's Companion CD-ROM These files are copyright protected by the publisher, author, and/or other third parties Unauthorized use, reproduction, or distribution is strictly prohibited File Description All CD Content Java InstantCode: Developing JSP and XML Integrated Solutions Size 126,103 Chapter 1 18,395 Chapter 2 24,930 Chapter 3 21,834 Chapter 4 14,980 Chapter 5 23,749 Chapter 6 8,697 Chapter 7 13,650 ... The book explains developing JSP and XML integrated solutions using XML- based JSP documents, the Java API for XML Processing (JAXP), and JDOM The book also explains how to develop custom tags and use pre existing tag... also develop XML- based JSP pages, known as JSP documents to develop Web applications XML- based JSP documents are JSP pages written in XML syntax A JSP document must comply with XML specifications All JSP documents need... Listing 1-7: The ViewAllItems.jspx File < ?xml version="1.0"?>

Ngày đăng: 25/03/2019, 17:10

Từ khóa liên quan

Mục lục

  • Table of Contents

  • Introduction

    • About the Book

    • Copyright

    • Point 1: Creating Web Applications Using XML-Based JSP Documents

      • Creating Database Tables

      • Creating the Logon Module

      • Creating the User Module

      • Creating the Administrator Module

      • Unit Testing

      • Point 2: Creating a JSP Application to Process and Transform XML Documents Using JAXP

        • Creating the XML Files

        • Creating the Logon Page

        • Creating the Logon Handler

        • Creating the Logout Page

        • Creating the Administrator Options Page

        • Creating the Add New User Page

        • Creating the Delete User Page

        • Creating the Add Music Album Page

        • Creating the Delete Music Album Page

        • Creating the Add Video Album Page

        • Creating the Delete Video Album Page

        • Creating the Purchase Album Page

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan