29.01.2013 Views

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The first role of a servlet is to act as a controller. A servlet is responsible for<br />

taking parameters from the client. It then gives these parameters to the<br />

appropriate components that handle the business logic. Finally, the servlet takes<br />

the results back and uses them to give a response to the user. The servlet can<br />

either return an HTML page to the user or forward the presentation task to a JSP.<br />

7.2 Studio Site Developer and servlets<br />

7.2.1 Wizards<br />

Studio Site Developer provides the necessary tools to build servlets, including:<br />

► Wizards<br />

► Web perspective<br />

► Deployment descriptor editor<br />

Studio Site Developer provides wizards that aid in the development of servlets.<br />

One is a Servlet wizard and the other is a Package wizard. The Package wizard<br />

is not required to create a servlet since the servlet wizard will place the servlet in<br />

the default package. If you would like to create your own package for<br />

organizational purposes, use the Package wizard.<br />

Package wizard<br />

To create new Java packages in the Package Explorer:<br />

1. Navigate to the JavaSource folder in your project.<br />

2. Right-click the JavaSource folder and select New > Other from the context<br />

menu.<br />

3. From the New dialog, select Java from the left pane and then select Package<br />

from the right pane.<br />

4. Click Next.<br />

5. Edit the Source Folder field to indicate in which container you want the new<br />

package to reside. You can either type a path or click Browse to find the<br />

container. If a folder was selected when you chose to create the new<br />

package, that folder appears in the Source Folder field as the container for the<br />

new package.<br />

6. In the Name field, type a name for the new package.<br />

Chapter 7. Working with servlets 221

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!