Transcription of with IBM WebSphere Studio and VisualAge for Java
1 And JSP Programmingwith IBM WebSphere Studio and VisualAge for JavaUeli WahliMitch FieldingGareth MackownDeborah ShaddonGert HekkenbergTeach yourself servlet and JSP programming techniquesDevelop and test with WebSphere Studio and VisualAge for JavaDeploy to WebSphere Application Server Servlet and JSP Programmingwith IBM WebSphere Studioand VisualAge for JavaMay 2000SG24-5755-00 International Technical Support Organization Copyright International Business Machines Corporation 2000. All rights to Government Users Documentation related to restricted rights Use, duplication or disclosure issubject to restrictions set forth in GSA ADP Schedule Contract with IBM Edition (May 2000)This edition applies to Ve r sio n of WebSphere Application Server, WebSphere Studio , and VisualAge for java for use with the Windows NT Operating System.
2 Many of the concepts also apply to these products running on AIX, UNIX, and OS/2 Operating may be addressed to:IBM Corporation, International Technical Support OrganizationDept. OWR Building 80-E2650 Harry RoadSan Jose, California 95120-6099 When you send information to IBM, you grant IBM a non-exclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to using this information and the product it supports, be sure to read the general information in Appendix D, Special notices on page Note! Copyright IBM Corp. 2000iiiContentsFigures .. xiiiTables .. xxiPreface.. xxiii Sample code on the Internet .. xxiiiThe team that wrote this redbook ..xxivComments welcome.
3 XxviPart 1. Web application development..1 Chapter 1. Environment overview.. 3 WebSphere execution environment .. 4 VisualAge for java development environment .. 5 WebSphere Studio development environment .. 6 VisualAge for java and WebSphere Studio interactions .. 7 Complete product environment .. 8 Chapter 2. Product overview.. 11 How the products work together .. 11 IBM HTTP Server.. 12 WebSphere Application Server .. 12 WebSphere Studio .. 14 VisualAge for java .. 15 Distributed Debugger .. 16DB2 Universal Database (UDB) .. 16 SecureWay Directory .. 16 Chapter 3. Product installation .. 17 Starting environment .. 17 Creating a dedicated user ID .. 18 java Development Kit .. 18 IBM HTTP Server.. 19 Installing the product.
4 19 Testing the install.. 19DB2 Universal Database .. 21 Installing the product .. 21 Testing the installation .. 22 VisualAge for java .. 24 ivServlet and JSP Programming with IBM WebSphere Studio and VisualAge for java Installing the product .. 24 Testing the installation .. 25 Existing errors .. 25 Distributed Debugger .. 26 WebSphere Application Server .. 26 Installing the product .. 26 Testing the installation .. 30 WebSphere Studio .. 33 Installing the product .. 33 Testing the installation .. 34 SecureWay Directory .. 35 Incompatibilities with DB2 UDB.. 35 Installing the product .. 35 Configuring SecureWay Directory .. 38 Testing the installation .. 40 What we have achieved .. 40 Chapter 4. Servlets.. 41 Overview of java servlets.
5 42 Servlet process flow .. 42 The java Servlet API .. 43 The servlet life cycle .. 44 Basic servlet examples .. 47 Simple HTTP servlet .. 47 HTML form generator servlet .. 51 HTML form processing servlet .. 53 Simple counter servlet .. 56 Servlet initialization parameters.. 58 HTTP request handling utility servlet .. 61 Additional servlet examples .. 62 Cookie servlet .. 62 URL rewriting servlet .. 64 A real persistent servlet between servlet life-cycle .. 65 User sessions.. 67 User session counter servlet .. 68 JDBC servlet .. 70 Servlet tag with SHTML .. 72 Servlet interaction techniques .. 73 Servlet collaboration: filtering and chaining.. 74 Calling servlets from servlets .. 79 Response redirection.. 79 Request dispatching.
6 81 Resource usage .. 84 Contentsv Sharing of objects in scope .. 86 New features of java Servlet API .. 92 Summary .. 94 Chapter 5. JavaServer Pages.. 95 Overview .. 96 How JavaServer Pages work .. 97 Components of JavaServer Pages .. 98 HTML tags .. 99 JSP directives .. 99 Declarations .. 101 Scriptlets .. 102 Comments .. 102 Expressions .. 102 WebSphere extensions to JSP scripting .. 103 Accessing implicit objects .. 104 Putting it all together.. 105 JSP interactions .. 107 Invoking a JSP by URL .. 107 Calling a servlet from a JSP .. 107 Calling a JSP from a servlet .. 109 Invoking a JSP from a JSP .. 111 Creating dynamic content in JSPs.. 111 Standard JSP tags .. 111 WebSphere -specific tags.. 116 JSP utility example.
7 122 Differences between JavaServer Page specification .91 and .. 122 Chapter 6. WebSphere Application Server .. 123 WAS overview .. 124 WAS administration .. 126 The administrative repository .. 126 The WebSphere Administrative Console.. 126 WAS Topology .. 128 Node.. 128 Application server.. 129 Servlet engine .. 130 Web application .. 131 Virtual host .. 132 Internal servlets .. 134 Creating your own Web application.. 135 Using the Task Wizard.. 135 Setting up your default error page .. 138 viServlet and JSP Programming with IBM WebSphere Studio and VisualAge for java Creating the required Web application directories.. 139 Deploying files to WAS.. 140 Defining servlets .. 140 Start the Web application .. 141 Class loading and reloading.
8 142 Changing the application server class path .. 142 Using JNI in WAS .. 143 Creating an application server environment variable .. 143 Setting up connection pools .. 145 Creating a JDBC driver .. 145 Creating a DataSource .. 146 Migrating from the connection manager.. 146 Using JavaServer Pages in WAS .. 147 Adding JSP support to a Web application.. 147 Keeping java source files from JSP compilation .. 148 Security .. 149 How security works in WAS.. 149 Configuring an enterprise application.. 150 Setting up security in WAS .. 152 XML configuration interface .. 162 Exporting configuration data .. 162 Importing configuration data.. 163 Examples.. 163 User profiling .. 164 Troubleshooting .. 164 Tracing within WAS .. 165 Monitoring resources.
9 166 Reference information .. 166 Chapter 7. Development and testing with VisualAge for java . 167 VisualAge for java overview .. 168 Application development with VisualAge for java .. 170 Rapid application development (RAD) .. 170 Create industrial-strength java applications .. 171 Maintain multiple editions of programs .. 171 VisualAge for java components .. 171 Navigating in VisualAge for java .. 175 Additional VisualAge for java concepts .. 181 Servlet development .. 185 Rapid servlet development.. 185 The development process .. 186 Developing our first servlet .. 187 WebSphere Test Environment .. 191 Contentsvii VisualAge for java configuration for WebSphere .. 192 WebSphere Test Environment setup.. 192 Start the WebSphere Test Environment.
10 192 What have we accomplished?.. 196 Testing JSPs under WebSphere Test Environment .. 197 VisualAge for java configuration for JSPs .. 197 Configuring the JSP version used by VisualAge for java .. 197 Running our first JSP.. 198 Creating and running a JSP .. 200 Debugging servlets and JSPs .. 201 Debugger basics .. 201 Debugging a servlet .. 203 JSP Execution Monitor.. 206 Debugging JSP generated source code .. 208 WebSphere Test Environment advanced configuration.. 208 Types of resources.. 209 Additional servlet examples.. 209 Resource locations .. 209 The four key configuration files .. 210 Configuration for servlet chaining, filtering, and SHTML.. 212 Developing and testing additional servlet and JSP configurations.