Servlet Wizard

The Servlet Wizard creates an Servlet consisting of two files and adds them to the existing project. (If no project is open, JBuilder runs the Project Wizard first before it runs the Servlet Wizard.)

The Servlet Wizard can create the following two files:

To open the Servlet Wizard, choose File|New, then double-click the Servlet icon. To get your servlet to compile, you must have JDK 1.2 and set it to use JDK 1.2 in the File|Project Properties option.

The Servlet Wizard consists of two pages:


Step 1 of 2

Servlet Class

The wizard displays default names for the Package and Servlet class file.

Package

Displays the package name derived from the project file. To assign a different package name to the Servlet file, click in the Package field and type in a new name.

For more information on packages, see the Packages topic in the "Creating and managing projects" of Getting Started with JBuilder.

Class

Displays the default name assigned to the Servlet class. To rename it, click in the Class field and type in a new name.

File

The full path and .java file name for the Servlet class. This file path and name is constructed from the source path node under which the project exists (as defined in File|Project Properties), plus the contents of the Package and Class fields. This field is not editable. If the path or name are not correct, edit the Package and Class name fields on this page of the wizard. The file will be created with the location and name indicated here.

Servlet Style

Implement SingleThreadModel

If checked, a "tagging" interface that instructs the web server to guarantee that only one invocation of the servlet may be active at one time is implemented.

Generate HTML page

Determines if a new HTML page is added to your project for this Servlet. If unchecked, no HTML page is generated.

Servlet Methods

Options for overriding the standard Servlet methods.

Generate service() method

The default implementation of the service() method delegates to one of the followng methods based on the type of the HTTP request received. Override only if you do not want this behavior.

Generate doGet() method

HTTP Get() requests are sent to this method. The default implementation does nothing.

Generate doPost() method

This method handles HTTP Post() requests. The default implementation does nothing.

Generate doPut() method

This method handles HTTP Put() requests. The default implementation does nothing.

Generate doDelete() method

This method handles HTTP Delete() requests. The default implementation does nothing.


Step 2 of 2

Servlet Parameters

The grid on this page is used to enter the information that defines the parameters for your Servlet. This information will generate PARAM tags within the FORM tag of the new HTML file, and parameter-handling code in the new Servletx.java file. Fields marked with an asterisk (*) are required fields.

Fill in one row of the grid for each parameter you wish to have.

Name

A name for the parameter. This will be used to provide the NAME attribute in the FORM tag in the HTML file, and to provide the name parameter of the corresponding getParameter() call in the Java source.

Type

A drop-down choice list from which you select the type of variable that will be inserted into the Java source code of your Servlet for holding the value of the parameter coming in from the HTML page.

Desc

A brief description of the parameter. This will be used to generate comments and to label the form field in the generated HTML file.

Variable

The name of the variable that will be inserted into the Java source code of your Servlet for holding the value of the parameter coming in from the HTML page.

Default

The default value for the parameter. This is the value that the Java source code in this Servlet will use if some future HTML file that uses this Servlet has no PARAM tag for this parameter. For an HTML file to provide this parameter, the NAME attribute in the PARAM tag must exactly match what you've entered in the Name column in this row of the grid. Note that this matching is case sensitive.

Method

The method that expects the parameter. A drop-down list of all the methods you chose to override, plus the init() method are presented. Init parameters are processed the very first time the servlet is invoked and are useful for global settings. The parameters for the other fields change with each HTTP request received.