Beginning JSP, JSF, and Tomcat Web Development

Beginning JSP, JSF, and Tomcat Web Development

CYAN YELLOW MAGENTA BLACK PANTONE 123 C EMPOWERING PRODUCTIVITY FOR THE JAVA™ DEVELOPER THE EXPERT’S VOICE® IN Java™ TECHNOLOGIES Companion eBook Available Beginning JSP,™ JSF,™ and Tomcat™ Web Development: From Novice to Professional Beginning Dear Reader, JSP, Beginning This book tells you what you need to know to develop Java™-based web applica- tions with JavaServer Pages™ (JSP™), JavaServer™ Faces (JSF™), and Tomcat.™ In less than one and a half decades, the Web has become a platform capable ™ ™ of delivering complex and powerful applications. At the same time, a bewilder- Giulio Zambon ing variety of technologies and products has been introduced, all jostling for recognition and market share. ™ We decided to write this manual on the basis of two considerations: one JSF, technical and one human in nature. The technical consideration was that the alignment of JSP 2.1 and JSF 1.2 achieved with Java Platform, Enterprise Edition JSP, JSF, 5 (Java EE 5), and the subsequent release of Servlet 2.5 and Tomcat 6, had finally realized full consistency across the whole platform. The human consideration ™ was that, although a lot of information and documentation is available by searching the Web, there is a need for a compendium capable of taking a reader through all the steps necessary to build a Java-based web application. ™ In our endeavor to cover all the subjects you’ll need, we have included chapters dedicated to HTML, JSP, databases, JSF, Tomcat, and XML, and sections on Java and and and HTTP. We’ve also touched on Cascading Style Sheets (CSS), JavaScript™, Tomcat Asynchronous JavaScript and XML (Ajax), and Simple Object Access Protocol (SOAP) and provided detailed references for HTML, JSP, JSF, and SQL. This is a practical manual driven by examples rather than by abstract con- Tomcat cepts. Nevertheless, we have consistently justified and explained every step Web Development taken and every choice made throughout the book. You’ll also discover useful tips and tricks to make your programming life easier. If you keep coming back to this book to look up techniques and to check out options and features, we will have achieved our goal. Happy programming! Giulio Zambon and Michael Sekler From Novice to Professional Companion eBook Learn and apply the very fundamentals of Java™ THE APRESS JAVA™ ROADMAP ™ ™ Pro JSP™ 2, 4th Ed. Web development using JSP and JSF API, and deployment using Apache Tomcat™ 6 server. See last page for details Beginning JSP™, on $10 eBook version Pro JSF™ and Ajax JSF™, and Tomcat™ ™ Pro Apache Tomcat™ 6 SOURCE CODE ONLINE Zambon, www.apress.com ISBN-13: 978-1-59059-904-4 Sekler java.apress.com ISBN-10: 1-59059-904-7 Giulio Zambon 5 3 9 9 9 with Michael Sekler US $39.99 Shelve in Java Programming User level: 9 781590 599044 Beginner–Intermediate this print for content only—size & color not accurate spine = 0.894" 472 page count 9047fmfinal.qxd 10/26/07 8:53 PM Page i Beginning JSP™, JSF™, and Tomcat Web Development From Novice to Professional Giulio Zambon with Michael Sekler 9047fmfinal.qxd 10/26/07 8:53 PM Page ii Beginning JSP™, JSF™, and Tomcat Web Development: From Novice to Professional Copyright © 2007 by Giulio Zambon with Michael Sekler 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 the copyright owner and the publisher. ISBN-13 (pbk): 978-1-59059-904-4 ISBN-10 (pbk): 1-59059-904-7 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. 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. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc., in the ™ US and other countries. Apress, Inc., is not affiliated with Sun Microsystems, Inc., and this book was writ- ten without endorsement from Sun Microsystems, Inc. Lead Editor: Steve Anglin Technical Reviewer: Kunal Mittal Editorial Board: Steve Anglin, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Jason Gilmore, Kevin Goff, Jonathan Hassell, Matthew Moodie, Joseph Ottinger, Jeffrey Pepper, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Project Manager: Richard Dal Porto Copy Editor: Nicole Abramowitz Associate Production Director: Kari Brooks-Copony Production Editor: Janet Vail Compositor: Linda Weidemann, Wolf Creek Press Proofreader: Linda Seifert Indexer: Toma Mulligan, Book Indexers Artist: April Milne Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit http://www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although every pre- caution has been taken in the preparation of this work, neither the author(s) nor Apress 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. The source code for this book is available to readers at http://www.apress.com. 9047fmfinal.qxd 10/26/07 8:53 PM Page iii Contents at a Glance About the Authors . xvii About the Technical Reviewer . xix Introduction. xxi ICHAPTER 1 Introducing JavaServer Pages and Tomcat . 1 ICHAPTER 2 JSP Explained . 25 ICHAPTER 3 The Web Page . 73 ICHAPTER 4 Databases. 121 ICHAPTER 5 At Face Value (JSF Primer). 145 ICHAPTER 6 Communicating with XML. 181 ICHAPTER 7 Tomcat 6 . 211 ICHAPTER 8 Eshop . 229 IAPPENDIX A Installing Everything . 251 IAPPENDIX B HTML Characters . 265 IAPPENDIX C HTML Reference . 273 IAPPENDIX D JSP Reference. 315 IAPPENDIX E SQL Quick Reference . 347 IAPPENDIX F JSF Quick Reference . 371 IAPPENDIX G Eclipse . 401 IAPPENDIX H Abbreviations and Acronyms . 415 IINDEX . 419 iii 9047fmfinal.qxd 10/26/07 8:53 PM Page iv 9047fmfinal.qxd 10/26/07 8:53 PM Page v Contents About the Authors . xvii About the Technical Reviewer . xix Introduction. xxi ICHAPTER 1 Introducing JavaServer Pages and Tomcat . 1 What Is JSP? . 2 Viewing a Web Page . 3 Viewing a JSP Page. 3 Hello World! . 5 JSP Application Architectures . 9 The Model 1 Architecture . 9 The Model 2 Architecture . 10 What Role Does Tomcat Play in All This? . 21 Summary. 24 ICHAPTER 2 JSP Explained . 25 Introduction . 25 Scripting Elements and Java. 26 Data Types and Variables. 26 Objects and Arrays . 28 Operators, Assignments, and Comparisons . 29 Selections . 30 Iterations . 31 The Online Bookshop . 32 Objects and Operations. 32 The Customer Interface . 33 The Eshop Architecture . 35 The Model . 35 The Controller. 35 The View . 37 v 9047fmfinal.qxd 10/26/07 8:53 PM Page vi vi ICONTENTS Summary of JSP Features . 38 Implicit Variables . 38 JSP Directives . 42 JSP Standard Actions . 43 Comments and Escape Characters . 47 JSP’s Tag Extension Mechanism . 48 Bodyless Custom Actions . ..

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    472 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us