|
|
Previous<
12
13
14
15
16
17
18
19
20
21
22
> Next
|
|
When an HTTP client such as web browser sends a request to a wen server, along with the request it also sends some HTTP variables like Remote address, Remote host, Content type etc. In some cases these variables are useful to the programmers. So here is the code of the jsp file which prints the HTTP request information:
|
|
|
|
getQueryString() returns the query string, everything after the '?'
Often, query strings are the result of form submissions but it's also useful for database-driven sites. For example, you might encode "story 15, comment 7" of a discussion as /comment.xtp?story=15&comment=7.
|
|
|
|
Following is a guide to installing and configuring Apache Tomcat 6 for use as a standalone Web server (for development) that supports servlets 2.5 and JSP 2.1. (Note: Apache Tomcat is sometimes referred to as "Jakarta Tomcat" since the Apache Java effort is known as "The Jakarta Project"). This Tomcat tutorial covers version 6.0.10, but the steps are almost the same for any Tomcat 6.0.x version. For coverage of Tomcat 5.5, see the separate Tomcat 5.5 tutorial. For coverage of very old Tomcat versions (Tomcat 5.0.x and Tomcat 4.0.x), please see the Apache Tomcat 5.0 and 4.0 tutorial.
|
|
|
|
Here's a simple example that reads parameters named param1, param2, and param3, listing their values in a bulleted list. Note that, although you are required to specify response settings (content type, status line, other HTTP headings) before beginning to generate the content, there is no requirement that you read the request parameters at any particular time.
Also note you can easily make servlets that can handle both GET and POST data, simply by having its doPost method call doGet or by overriding service (which calls doGet, doPost, doHead, etc.). This is good standard practice, since it requires very little extra work and permits flexibility on the part of the client. If you're used to the traditional CGI approach where you read POST data via the standard input, you should note that there is a similar way with servlets by first calling getReader or getInputStream on the HttpServletRequest. This is a bad idea for regular parameters, but might be of use for uploaded files or POST data being sent by custom clients rather than via HTML forms. Note, however, that if you read the POST data in that manner, it might no longer be found by getParameter.
|
|
|
|
Business code, which is logic that solves or meets the needs of a particular business domain such as banking, retail, or finance, is handled by enterprise beans running in the business tier. Figure 1-4 shows how an enterprise bean receives data from client programs, processes it (if necessary), and sends it to the enterprise information system tier for storage. An enterprise bean also retrieves data from storage, processes it (if necessary), and sends it back to the client program.
|
|
|
|
| Previous< 12 13 14 15 16 17 18 19 20 21 22 > Next |
|
|
|
|
|
|
|
|
|
|
|
|
|
|