InfoCenter Home >
4: Developing applications >
4.2: Building Web applications >
4.2.4: Putting it all together (Web applications) >
4.2.4.4: Providing ways for clients to invoke applications >
4.2.4.4.1: Providing Web clients access to JSP files >
4.2.4.4.1.2: Invoking servlets and JSP files within HTML forms

4.2.4.4.1.2: Invoking servlets and JSP files within HTML forms

A Web page can be designed so that users can invoke a servlet or JSP file from an HTML form. An HTML form enables a user to enter data on a Web page (from a browser) and submit the data to a servlet, or a servlet generated by a JSP file.

The HTML FORM tag has attributes for specifying how to invoke the servlet or JSP file:

FORM attribute Description
METHOD Indicates how user information is to be submitted.
ACTION Indicates the URL used to invoke the servlet or JSP file

If the information entered by the user is to be submitted to a servlet by a GET or POST method, the servlet must override the doGet() method or doPost() method. For JSP files, the override is not necessary. The same service method that is called whether the form is submitted using GET or POST.

Examples

Using GET:

<FORM METHOD="GET" ACTION="/application_Web path/servlet_Web_path">
<!-- HTML tags for text entry areas, buttons, and other prompts go here -->
</FORM>

Using POST:

<FORM METHOD="POST" ACTION="application_Web_path/servlet_Web_path">
<!-- HTML tags for text entry areas, buttons, and other prompts go here -->
</FORM>

Go to previous article: Invoking servlets and JSP files by URLs Go to next article: Example: Invoking servlets within HTML forms

 

 
Go to previous article: Invoking servlets and JSP files by URLs Go to next article: Example: Invoking servlets within HTML forms