Professional Java for Web Applications(Wrox,2014)

所需积分/C币:15 2015-04-01 19:05:01 11.4MB PDF

This guide shows Java software developers and software engineers how to build complex web applications in an enterprise environment. You'll begin with an introduction to the Java Enterprise Edition and the basic web application, then set up a development application server environment, learn about t
PROFESSIONALS Java for Web applications Nicholas s. Williams A Wiley Brand 19-02-201412:20:4L Professional Java@ for Web Applications Published by ohn Wiley Sons. Ir 10475 Crosspoint Boulevard Indianapolis, IN 46256 Copyright o 2014 by John Wiley Sons, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN:978-1118656464 ISBN:978-1-118-65651-8(ebk) ISBN:978-1-118-90931-7ebk) Manufactured in the united states of a merica 10987654321 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the publisher or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers MAO1923,(978)750-8400, fax(978)646-8600 Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley Sons, Inc, 111 River Street, Hoboken, N 07030, (201)748-6011, fax(201) 748-6008,oronlineat Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sale promotional materials. the advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written anld when it is read For general information on our other products and services please contact our Customer Care Department within the United States at(877)762-2974, outside the United States at(317)572-3993 or fax(317)572-4002 Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not bc included in c-books or in print-on-dcmand If this book rcfcrs to media such as a CD or dVd that is not included in the version you purchased, you may download this material at Library of Congress Control Number: 2013958292 Trademarks: Wiley, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley sons, InC and/or its affiliates, in the United States and other countries, and may not be used without written permission. Java is a registered trademark of Oracle America, Inc. all other trademarks are the property of their respective owners. John Wiley Sons, Inc, is not associated with any product or vendor mentioned in this book firs indd 2 24-02201412:35:52 ABOUT THE AUTHOR NICK WILLIAMS is a Software Engineer for UL Workplace Health and Safety in Franklin, Tennessee. A computer science graduate from Belmont University he has been active in commercial and open source software projects for more than 9 years. He is the founder of dNscrawler site for free dn IP troubleshooting tools, and nwts Java Code, an open source community that specializes in obscure Java libraries that meet niche needs. In 2010, the Nashville technology council named him the software Engineer of the year for Middle Tennessee. Nick is a committer for Apache Logging(including Log4j) and Jackson Data Processor JSR 310 Data Types. He has also contributed new features to Apache Tomcat 8.0, Spring Framework 4.0, Spring Sccurity 3. 2, Spring Data Commons 1.6, Spring Data JPA 1.4, and boss logging 3.2; serves as a contributor on several other projects, including Open jDK and is a member of the Java Community Process(jCP Nick currently lives in Tennessee with his wife Allison. You can find him on twitter @Java_ Nick ABOUT THE TECHNICAL EDITORS JAKE RADAKOVICH joined UL Workplace Health and Safcty in 2009, and currently serves as Software Developer on the Occupational Health Manager product. Prior to that, he was a research assistant at Middle Tennessee State University working on algotutor, a web-based algorithm development tutoring system. He holds a BS in Computer Science and mathematics from Middle Tennessee State University. You can follow Jake on Twitter JakeRadakovich MANUEL JORDAN ELERA is an autodidactic developer and researcher who enjoys learning new technologies for his own experiments and creating new integrations. l le won the 2010 Springy Award and was a Community Champion and Spring Champion in 2013. In his little free time he reads the bible and composes music on his guitar. Manuel is a Senior Member in the Spring Community Forums known as dr_pompeii. You can read about him and contact him through his blog and you can follow him on his Twitter account, @dr_pompeii firs. indd 3 24-02201412:35:53 CREDITS ACQUISITIONS EDITOR MARKETING MANAGER Mary James Ashley Zurch PROJECT EDITOR BUSINESS MANAGER Maureen Spears tull Amy Knie TECHNICAL EDITORS VICE PRESIDENT AND EXECUTIVE GROUP Michael jordan elera PUBLISHER Rⅰ chard swad TECHNICAL PROOFREADER ASSOCIATE PUBLISHER Jonathan giles Jim minate SENIOR PRODUCTION EDITOR PROJECT COORDINATOR COVER Kathleen wisor Todd Klemme COPY EDITOR PROOFREADERS Apostrophe editing services Nancy Carrasco Josh Chase, Word One EDITORIAL MANAGER Mary beth Wakefield INDEXER Robert swanson FREELANCER EDITORIAL MANAGER R。 semarie Graham COVER DESIGNER Wile ey ASSOCIATE DIRECTOR OF MARKETING David mayhew COVER IMAGE iStockphoto. com/Elementallmaging ffirs indd 4 24-02201412:35:53 ACKNOWLEDGMENTS THANKS TO My wife allison, whose unwavering support and persistent reminders about deadlines during Is stressful year ma ok possible My parents and siblings, who told me that i could do anything i put my mind to Drs. Joyce Blair Crowell and William Hooper, whose dedicated instruction and mentoring made my career possible Dr. Sarah Ann Stewart, who believed in me when I thought surely calculus and proofs spelled doom for my education Mrs. Lockhart, who inspired me to write Jay, for introducing me to Mary, and to Mary and Maureen for making this book a reality Jake, for being absurd. Oh, and for agreeing to be my technical editor. 24-02201412:35:53 ffirs indd 6 24-02201412:35:53 CONTENTS INTRODUCTION XXII PART I: CREATING ENTERPRISE APPLICATIONS CHAPTER 1: INTRODUCING JAVA PLATFORM ENTERPRISE EDITION 3 A Timeline of Java Platforms In the Beginning The Birth of Enterprise Java Java se and java eE evolving Together 34569 Understanding the Most Recent Platform Features A Continuing Evolution Understanding the Basic Web Application Structure 13 Servlets, Filters, Listeners, and JSPs 13 Directory structure and war files 14 The Deployment Descriptor 15 Class loader architecture 16 Enterprise Archives Summary Q CHAPTER 2: USING WEB CONTAINERS 19 Choosing a Web Container 19 Apache Tomcat 20 GlassFish 21 JBoss and wildE 22 Other Containers and Application Servers 22 Why You'l Use Tomcat in This Book 23 Installing Tomcat on Your Machine 23 Installing as a Windows Service 24 Installing as a Command-Line Application 24 Configuring a Custom JSP Compiler 26 Deploying and Undeploying Applications in Tomcat 27 Performing a Manual Deploy and Undeploy 28 Using the tomcat manager 28 1-02-2014 CONTENTS Debugging Tomcat from Your IDE 30 Using IntelliJ IDEA 30 Using Eclipse 35 Summary 39 ChAPTER 3: WRITING YOUR FIRST SERVLET 41 Creating a Servlet Class 42 What to Extend 42 Using the Initializer and destroyer 45 Configuring a Servlet for Deployment 46 Adding the servlet to the descriptor 46 Mapping the servlet to a URL 47 Running and Debugging Your Servlet 49 Understanding do Get(), do Posto, and Other Methods 51 What Should Happen during the service method e xecution ? Using Http Servletrequest 52 Using Http servletrEsponse 55 Using Parameters and Accepting Form Submissions 56 Configuring your Application Using Init Parameters Using Context Init Parameters Using Servlet Init Parameters 62 Uploading Files from a Form 64 Introducing the Customer Support Project 65 Configuring the Servlet for File Uploads 65 Accepting a File Upload 68 Making Your Application Safe for Multithreading 69 Understanding Requests, Threads, and Method Execution 69 Protecting Shared Resources 70 Summar 71 CHAPTER 4: USING JSPS TO DISPLAY CONTENT 73 <br / ls Easier Than output. printin ("<br />") 74 Why JSPs are bette 75 What Happens to a jsp at Run Time 76 Creating Your First JSP 78 Understanding the file structure 78 Directives, Declarations, Scriptlets, and Expressions 79 Commenting Your Code Adding Imports to Your JSP 82 itoc indd 8 1-02-201408:39:54


关注 私信 TA的资源