Servlet and JSP Programming with IBM WebSphere Studio and VisualAge for Java

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

This IBM Redbook provides you with sufficient information to effectively use the WebSphere and VisualAge for Java environments to create, manage and deploy Web-based applications using methodologies centered around servlet, JavaServer Pages, and JavaBean architectures.

In Part 1 we describe the products used in our environment and provide instruction on product installation and configuration. Following this, we cover servlet and JSP programming, which provide you with both a theoretical and practical understanding of these components, together with working examples of the concepts described. For execution of the sample code, we provide information on configuring the WebSphere Application Server and deploying and running the sample Web applications in WebSphere. Using the knowledge developed in these chapters, we then provide detailed information on the development environments offered by VisualAge for Java and WebSphere Studio. These chapters assist you in using the features offered by these tools, such as integrated debugging, the WebSphere Test Environment, Studio Wizards, and publishing of Web site resources. We also describe how Rational's ClearCase product can be integrated with our environment for Software Configuration Management.

In Part 2 we describe the Pattern Development Kit sample application, including installation, configuration, and operation. We also discuss the application's use of Patterns for e-business, which presents information on some of the design decisions employed when creating the application.

This IBM Redbook is intended to be read by anyone who requires both introductory and detailed information on software development in the WebSphere environment using servlets and JavaServer Pages. We assume that you have a good understanding of Java and some knowledge of HTML.

Author(s): IBM Redbooks
Series: IBM Redbooks
Publisher: IBM Press
Year: 2000

Language: English
Pages: 480

Contents......Page 5
Figures......Page 15
Tables......Page 23
Sample code on the Internet......Page 25
The team that wrote this redbook......Page 26
Comments welcome......Page 28
Part 1 Web application development......Page 29
1 Environment overview......Page 31
WebSphere execution environment......Page 32
VisualAge for Java development environment......Page 33
WebSphere Studio development environment......Page 34
VisualAge for Java and WebSphere Studio interactions......Page 35
Complete product environment......Page 36
How the products work together......Page 39
WebSphere Application Server......Page 40
WebSphere Studio......Page 42
VisualAge for Java......Page 43
SecureWay Directory......Page 44
Starting environment......Page 45
Java Development Kit......Page 46
Testing the install......Page 47
Installing the product......Page 49
Testing the installation......Page 50
Installing the product......Page 52
Existing errors......Page 53
Installing the product......Page 54
Testing the installation......Page 58
Installing the product......Page 61
Testing the installation......Page 62
Installing the product......Page 63
Configuring SecureWay Directory......Page 66
What we have achieved......Page 68
4 Servlets......Page 69
Servlet process flow......Page 70
The Java Servlet API......Page 71
The servlet life cycle......Page 72
Simple HTTP servlet......Page 75
HTML form generator servlet......Page 79
HTML form processing servlet......Page 81
Simple counter servlet......Page 84
Servlet initialization parameters......Page 86
HTTP request handling utility servlet......Page 89
Cookie servlet......Page 90
URL rewriting servlet......Page 92
A real persistent servlet — between servlet life-cycle......Page 93
User sessions......Page 95
User session counter servlet......Page 96
JDBC servlet......Page 98
Servlet tag with SHTML......Page 100
Servlet interaction techniques......Page 101
Servlet collaboration: filtering and chaining......Page 102
Response redirection......Page 107
Request dispatching......Page 109
Resource usage......Page 112
Sharing of objects in scope......Page 114
New features of Java Servlet API 2.2......Page 120
Summary......Page 122
5 JavaServer Pages......Page 123
Overview......Page 124
How JavaServer Pages work......Page 125
Components of JavaServer Pages......Page 126
JSP directives......Page 127
Declarations......Page 129
Expressions......Page 130
WebSphere extensions to JSP scripting......Page 131
Accessing implicit objects......Page 132
Putting it all together......Page 133
Calling a servlet from a JSP......Page 135
Calling a JSP from a servlet......Page 137
Standard JSP tags......Page 139
WebSphere-specific tags......Page 144
Differences between JavaServer Page specification .91and1.0......Page 150
6 WebSphere Application Server......Page 151
WAS overview......Page 152
The WebSphere Administrative Console......Page 154
Node......Page 156
Application server......Page 157
Servlet engine......Page 158
Web application......Page 159
Virtual host......Page 160
Internal servlets......Page 162
Using the Task Wizard......Page 163
Setting up your default error page......Page 166
Creating the required Web application directories......Page 167
Defining servlets......Page 168
Start the Web application......Page 169
Changing the application server class path......Page 170
Creating an application server environment variable......Page 171
Creating a JDBC driver......Page 173
Migrating from the connection manager......Page 174
Adding JSP support to a Web application......Page 175
Keeping Java source files from JSP 1.0 compilation......Page 176
How security works in WAS......Page 177
Configuring an enterprise application......Page 178
Setting up security in WAS......Page 180
Exporting configuration data......Page 190
Examples......Page 191
Troubleshooting......Page 192
Tracing within WAS......Page 193
Reference information......Page 194
7 Development and testing with VisualAge for Java......Page 195
VisualAge for Java overview......Page 196
Rapid application development (RAD)......Page 198
VisualAge for Java components......Page 199
Navigating in VisualAge for Java......Page 203
Additional VisualAge for Java concepts......Page 209
Rapid servlet development......Page 213
The development process......Page 214
Developing our first servlet......Page 215
WebSphere Test Environment......Page 219
Start the WebSphere Test Environment......Page 220
What have we accomplished?......Page 224
Configuring the JSP version used by VisualAge for Java......Page 225
Running our first JSP......Page 226
Creating and running a JSP......Page 228
Debugger basics......Page 229
Debugging a servlet......Page 231
JSP Execution Monitor......Page 234
WebSphere Test Environment — advanced configuration......Page 236
Resource locations......Page 237
The four key configuration files......Page 238
Configuration for servlet chaining, filtering, and SHTML......Page 240
Creating additional servlet examples......Page 242
Configuring multiple Web applications......Page 243
Configuring the ServletEngine class......Page 245
Launching ServletEngine......Page 247
Using the ServletEngineConfigDumper servlet......Page 248
Restoring SERunner......Page 249
Team development......Page 250
Overview......Page 251
Resource management......Page 253
8 Development with WebSphere Studio......Page 255
WebSphere Studio overview......Page 256
Creating a project......Page 258
Setting the JSP version......Page 260
Setting up folders......Page 261
Adding files to the project......Page 262
Setting the file status......Page 264
Checking-out and checking-in files......Page 265
Invoking Page Designer......Page 266
Using forms and input fields......Page 267
Calling a servlet......Page 269
Preview the form and view HTML source......Page 270
Inserting a JavaBean into a JSP......Page 272
Modifying JavaBeans and servlets......Page 274
Publishing stages and publishing targets......Page 275
Setting up the Test stage......Page 276
Setting up the Production stage......Page 278
Publishing to a Web application......Page 279
Project relationships and integrity......Page 281
Publishing a project......Page 283
Testing published files......Page 284
Code produced by the wizards......Page 285
Run the SQL Wizard......Page 286
Changing the SQL statement......Page 292
Run the Database Wizard......Page 293
Database Wizard generated code......Page 298
Run the generated application......Page 300
Enhance the application......Page 301
Run the JavaBean Wizard......Page 304
JavaBean Wizard — what for?......Page 308
Create the SQL statement for the employees of a department......Page 309
Create the SQL statement for the employee photo......Page 310
Change the generated DataSource......Page 311
Testing in VisualAge for Java......Page 312
Displaying a picture......Page 313
Linking the servlets......Page 314
Run the application......Page 316
Resolving parsing problems......Page 317
JavaBean Wizard generates bad code......Page 318
Setting up the environment......Page 319
Receiving updates from Visual Age for Java......Page 320
Opening an archive......Page 321
More information and examples......Page 322
9 Software Configuration Management......Page 323
What is Software Configuration Management?......Page 324
SCM for architectural pattern based development......Page 326
Developer roles......Page 327
SCM aspects......Page 330
ClearCase......Page 334
Unified Change Management......Page 335
Our approach......Page 336
Installation......Page 337
WebSphere Studio and ClearCase considerations......Page 340
Setting up a ClearCase project......Page 341
Create the project......Page 343
Create a view......Page 348
Enable ClearCase to the WebSphere Studio environment......Page 350
Bring the projects artifacts under ClearCase control......Page 351
Working from WebSphere Studio......Page 353
Reflections on SCM procedures......Page 355
Rational Rose......Page 356
Epilog......Page 358
Application structure......Page 359
Data beans......Page 361
Detailed information......Page 362
Part 2 Pattern Development Kit: a sample application......Page 363
11 Pattern Development Kit overview......Page 365
Application walkthrough......Page 366
Home page......Page 367
Topology 1 — historical data......Page 369
Topology 2 -— visit planets......Page 371
12 Using Patterns for e-business to build the PDK......Page 375
Choose a business pattern......Page 376
Choose a related logical pattern......Page 377
Choose a related physical pattern......Page 379
The Model-View-Controller framework......Page 381
The Command bean design pattern......Page 382
Topology 1......Page 383
Topology 2......Page 385
In Summary......Page 389
13 Running the PDK in WebSphere......Page 391
Set up environment parameters......Page 392
Tailor the XML files......Page 393
Create a self-signed SSL certificate......Page 395
Configure IBM HTTP Server......Page 397
LDAP configuration......Page 398
Copy application-specific files......Page 400
Run the application......Page 401
Resetting changes......Page 402
14 Running the PDK in VisualAge for Java......Page 403
Running the configuration script......Page 404
Servlet engine configuration......Page 405
Manual configuration......Page 406
Running the application......Page 408
Resetting changes......Page 409
15 Developing the PDK using WebSphere Studio......Page 411
Overview......Page 412
Creating the WebSphere Studio project......Page 413
Define the publishing stages......Page 414
Updating from VisualAge for Java......Page 417
Editing Studio files with VisualAge for Java......Page 418
Integrity checking for broken links......Page 421
Publishing to WebSphere Application Server......Page 423
Publishing report......Page 424
Editing files......Page 425
Appendixes......Page 427
JSP tag syntax summary......Page 429
WebSphere specific tags......Page 432
B Utility servlet and utility JSP......Page 435
ServletEnvironmentSnoop servlet source......Page 436
ServletEnvironmentSnoop servlet output......Page 441
WebPaths.jsp output......Page 443
Locating the additional material on the Internet......Page 445
How to use the Web material......Page 446
Directory structure......Page 447
Web application......Page 448
WebSphere Studio project......Page 449
Servlet configuration files......Page 450
Testing the servlets and JSPs......Page 451
Additional servlet examples......Page 452
Servlet interaction techniques......Page 454
JSP testing......Page 455
D Special notices......Page 457
E Related publications......Page 461
IBM Redbooks publications......Page 462
Other resources......Page 463
Referenced Web sites......Page 464
How to get IBM Redbooks......Page 465
IBM Redbooks fax order form......Page 466
Glossary......Page 467
Index......Page 469
IBM Redbooks review......Page 475