Out
Out. Print (); // output data
Out. newline (); // output a line break
Out. Flush (); // output data in the buffer
Out. Close (); // close the output stream.
Out. clearbuffer (); // clear the data in the buffer and output the data to the client.
Out. Clear (); // clears the data in the buffer, but does not output the data to the client.
Out. getbuffersize (); // obtain the buffer size
Out. getremaining (); // obtain the space not occupied in the buffer.
Out. isautoflush (); // returns a Boolean value. Returns true if autoflush is true.
Request
Isuserinrole (string role) determines whether the authenticated user is a member of the logical role.
Getattribute (string name) returns the attribute value specified by name. Null if it does not exist
Getattributes () returns the name set of all attributes of the request object. The result is an enumerated instance.
Getcookies () return all cookie objects on the client. The result is an array of cookies.
Getcharacterencoding () returns the character encoding method in the request.
Getcontentlength () returns the length of the Request body. If the length is not determined,-1 is returned.
Getheader (string name) obtains the header information defined by the HTTP protocol.
Getheaders (string name) returns all the values of the request header with the specified name. The result is an enumerated instance.
Getheadernames () returns the names of all request headers. The result is an enumeration instance.
Getinputstream () returns the input stream of the request to obtain data in the request.
Getmethod () is used to obtain data transmitted from the client to the server, such as get, post, header, and trace.
Getparameter (string name) obtains the parameter value sent from the client to the server.
Getparameternames () obtains the names of all parameters sent from the client to the server. The result is an enumerated instance.
Getparametervalues (string name) obtains all values of the specified parameter.
Getprotocol () obtains the protocol name used by the client to transmit data to the server.
Getquerystring () is used to obtain the query string, which is transmitted by the client to the server in get mode.
Getrequesturi () obtains the client address of the request string.
Getremoteaddr () obtains the Client IP Address
Getremotehost () Get the client name
Getsession ([Boolean create]) returns the session associated with the request. The create parameter is optional. When the create parameter is available and the value of this parameter is true, if the client has not created a session, a new session will be created.
Getservername () gets the server name
Getservletpath () obtains the file path of the script file requested by the client.
Getserverport () gets the server port number
Removeattribute (string name) deletes an attribute in the request.
Setattribute (string name, java. Lang. Object OBJ) sets the request parameter value
response
addcookie (cookie cook) to add a cookie object, used to save client User Information
addheader (string name, string value) add HTTP file header information. The header information will be transmitted to the client. If the same name already exists, it will overwrite
containsheader (string name) to determine whether the header of the specified sentence already exists, returns true or false.
encodeurl () uses sessionid to encapsulate the URL. If the URL is not encapsulated, the original value
flushbuffer () is returned to force the content of the current buffer to be sent to the client
getbuffersize () returns the buffer size
getoutputstream () the output stream
senderror (INT) returned to the client sends an error message to the client. If 404 means that the webpage does not exist
sendredirect (string location), send the response to another location for processing
setcontent (string contenttype) set the MIME type of the response
setheader (string name, string value) to set the value of the HTTP file header with the specified name. If yes, it will overwrite.
session
getattribute () obtains the attributes associated with the specified name.
each object stored in the getattributenames () Session object is an enumerated instance.
getcreatetime () returns the creation time of the session. The minimum unit is 1‰ seconds.
GETID () returns a unique identifier. the IDs of each session are different.
getlastaccessedtime () return the final request time sent by the client related to the current session object
getmaxinactiveinterval (). A negative value indicates that the session will never expire. The value is the survival time of the session
invalidate () to destroy this object.
isnew () if the client does not accept the use of session, each request generates a session object.
removeattribute (string name) deletes the attribute associated with the specified name
setattribute (string name, Java. langobject OBJ) sets the attribute value of the specified name and stores it in the session.
pagecontext
forward (string uripath) redirection
getattribute (string name, [int Scope]) scope is optional. It is used to retrieve the range of a specified named object. You can also call the getattributenamesinscope () method to retrieve the enumeration of each attribute string name in a specific range.
getexception () returns the current exception object
getrequest () returns the current request object
getresponse () returns the current response object
getservletconfig () the servletconfig object
getservletcontext () on the current page is returned. This object is shared with all pages.
getsession () returns the current session object.
findattribute () can be used to request the page, sessions and applications Program are used to search for a named attribute in sequence.
setattribute () can be used to set named objects in the default page range or specific range. Removeattribute () can be used to delete named objects in the default range or within a specific range.
Application
Getattribute (string name) returns the attribute value of the Application object with the specified name.
Getattributenames () returns the attribute names of all application-level objects. The result is an enumerated instance.
Getinitparameter (string name) returns the initial value of an attribute of the Application object with the specified name.
Getservletinfo () returns the current version of the servlet compiler.
Setattribute (string name, object OBJ) sets the attribute value of the Application object with the specified name
Config
Getservletcontext () returns the servlet context of the performer.
Getservletname () returns the servlet name
Getinitparameter (string name) returns the value of the initial parameter named name.
Getinitparameternames () returns the names of all the initial parameters of this JSP.
Exception
Exception object. Let me use an example program to demonstrate it!
Error. jsp
<% @ Page Language = " Java " Import = " Java. util .* " Pageencoding = " GBK " Iserrorpage = " True " %>
<% --To use the exception object, the iserrorpage of the page must be specified as true-- %>
< Html >
< Head >
< Title > Error demo </ Title >
</ Head >
< Body >
Error! < BR >
The following error occurs:
< BR > < BR > < HR > < Font Color = Red >
<% = Exception. getmessage () %>
</ Font >
</ Body >
</ Html >
TestCode
<% @ Page Language = " Java " Import = " Java. util .* " Pageencoding = " GBK " Errorpage = " Error. jsp " %>
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en" >
< Html >
< Head >
< Title > My JSP 'exception. jsp 'starting page </ Title >
</ Head >
< Body >
<%
Integer. Parseint ("Eflylab");//It will throw an exception
%>
</ Body >
</ Html >
Run
Note that the iserrorpage value in the exception object page must have a true market value. The default value is false. Therefore, the exception object is generally used as an example of the above program and used in friendly display of error pages.