2007-4-13
____________________________________________________________________________________________
1. Web servers are used to process HTTP requests, while application servers are used to provide services related to Web applications.
2. servlet uses the getparameter () method of the httpservletrequest class to retrieve data from the webpage.
Data is transcoded when transmitted over HTTP. Therefore, transcoding must be performed in a lubricant location before it can be correctly received.
Data.
 
2007-4-16
____________________________________________________________________________________________
1. response. sendredirect (string Str)
 
2. response. setheader (string str1, string str2)
 
3. Unlike other hidden objects, session objects can be used on any JSP page,
When the attribute session of the page command is set to false, the session object will produce a compilation error.
 
4. About pagecontext
By default, the scope of pagecontext is its webpage, but its function is far more than this.
On the one hand, it can read and set the attributes of four objects with different scopes (through its setattribute () and getatrribute ()
Add an int parameter to the method to specify the domain in which the read and set attributes are located)
On the other hand, it also has the ability to obtain the session/Request/response/Application implicit object in the current page!
 
2007-4-17
____________________________________________________________________________________________
1. About HTTP requests and responses
 
HTTP uses a very simple communication model: request and response mode.
When the client needs to obtain resources or apply for services, it will send a request to the server, then the Server accepts the request and gives a response.
Both requests and responses in HTTP have fixed forms:
 
A request mainly contains a request line and a request header and a request body. For example:
 
GET/index.html HTTP/1.1/* request line */
 
HOST: www.gefionsoftware.com/* Request Header mark */
User-Agent: Mozilla/5.0 (windows; U; Win 9x4.90; en-US; RV: 1.0.2)
Accept: image/GIF, image/JPEG, image/pjpeg, image/PNG ,*/*
Accept-language: En
Accept-charset: iso-8859-1, *, UTF-8
 
A response mainly contains a response line, a response header, and an optional response body (such as an HTML code)
 
HTTP/1.1 200 OK // response line. 200 indicates the response code, which indicates the response status,
 
Last-modified: Mon, 20 Dec 2002 23:26:42 GMT // The following is the Response Header
Date: Tue, 11 Jan 2003 20:52:40 GMT
Status: 200
Content-Type: text/html
Servlet-engine: Tomcat web server/5.0
Content-Length: 59
<HTML> // The following is the response body.
<Body>
<H1> Hello world! </H1>
</Body>
</Html>
 
2. Transmission Method of Request Parameters
In a request, the useful request information is the request parameter, which is a map consisting of key-value pairs.
There are two transmission methods for these parameters: Get and post.
The difference between the two methods is:
1) The get method converts parameters to query strings, adds them to the specified URL, and links them to the specified URL.
The specified program is used for processing.
2) The post method transmits the parameters as part of the Request body. No relevant information is found in the URL.
Generally, get is used to send requests with less information (less than 255 characters)
Post is used to send requests with a large amount of information. In addition, when passing user names and passwords, to prevent them from appearing in URLs
The post method should be used.
 
3. All controls must be placed in <form>... </form>.
 
2007-4-19
_____________________________________________________________________________________________________________________
1. jsp commands. (page/include/taglib)
 
A directive doesn't directly affect the content of the response sent to the browser, but it tells the container how it shoshould handle the page
 
A JSP command does not affect the specific content of the response sent to the browser, but it tells the container how to handle this page.
 
 
 
2009-8-
 
 
 
 
 
1. servlet Lifecycle
 
The servlet is normally
Created when a user first invokes a URL corresponding to the servlet, but you
Can also specify that the servlet be loaded when the server is first started.
 
Servlet is delayed by default. That is, the servlet container will create the servlet instance only when the request is delegated to the servlet for the first time, and then call the init Method for initialization. When another request arrives, the container will start a new thread or allocate an idle thread from the thread pool to perform the service method in the thread. The main task of the service method is to view the HTTP request, find the method to submit the request (such as get and post), and then call the corresponding doxxx method to process the request.
 
The following servlet lifecycle:
 
 
 
 
2. servlet class hierarchy
 
 
 
 
3. About httpservletrequest and httpservletresponse
 
 
 
Q: Who implements the interfaces for httpservletrequest and httpservletresponse? Are those classes in the API?
A: The container, and no. the classes aren't in the API because They're left to the vendor to implement. the good news is, you don't have to worry about it. just trust that when the service () method is called in your servlet, It'll be handed references to two perfectly good objects that implement httpservletrequest and httpservletresponse. you shoshould never care about the actual implementation class name or type. all you care about is that you'll get something that has all the functionality from httpservletrequest and httpservletresponse.
In other words, all you need to know are the methods you can call on the objects the container gives you as part of the request! The actual class in which they're implemented doesn' t matter to you-you're referring to the request and response objects only by the interface type.
 
 
 
Remember: Both httpservletrequest and httpservletresponse are interfaces. Platform APIs do not have any implementation classes for these two interfaces. Their implementation classes are defined and created by servlet containers. for developers, you don't need to understand this. You only need to use the interface.
 
 
 
4. Why are there genericservlet, servletrequest, and servletresponse? Instead of retaining the corresponding classes with HTTP headers?
 
Q: I'm still confused about why there's a genericservlet and servletrequest and servletresponse. If nobody's doing anything doesn't HTTP servlets... then what's the point?
A: We didn't say nobody. somebody, somewhere, one cocould imagine, is using the Servlet technology model without the HTTP protocol. just nobody we 've met personally or read about. ever.
Still, the flexibility was designed into the servlet model for those who might want to use servlets with, say, SMTP or perhaps a proprietary protom protocol. the only support built-in to the API, though, is for HTTP, and that's what exactly ally everyone's using.
 
The reason is: in principle, Servlet technology does not only work with the HTTP protocol. In theory, servlet can work with various protocols at the application layer, such as SMTP, FTP, and talnet. This is the intention of designing genericservlet, servletrequest, and servletresponse. They can expand classes like ftpservlet and ftprequest so that servlet can work with other application layer protocols.
 
 
 
 
 
 
 
5. servlet lifecycle and request focus: