InfoCenter Home >
4: Developing applications >
4.2: Building Web applications >
4.2.4: Accessing data >
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.1: Example: Invoking servlets within HTML forms
4.2.4.4.1.2.1: Example: Invoking servlets within HTML forms
Suppose the application programmer uses an HTML form to
provide users access to a servlet. Assuming the METHOD attribute
on the FORM tag is "GET," the flow is as follows:
- The user views the form in a browser. The user provides
information requested by the form and specifies to submit the
form (usually by clicking a Submit button or other button visible
on the form).
- The form encodes the user-supplied information into a URL-encoded
query string. It appends the query string to the servlet URL and
submits the entire URL.
- The servlet processes the information. The getParameterNames(), getParameter(), and
getParameterValues() methods of the HttpServletRequest object provide access
to the form parameter names and values in the client request.
The extraction process also decodes the names and values.
- Often, the final action of the servlet is to dynamically create an HTML
response (based on parameter input from the form) and pass it back to the user
through the server. Methods of the HttpServletResponse object are used
to send the response, which is sent back to the client as a complete HTML
page.
|
|