Built-in objects are objects that can be directly used in JSP without being declared. jsp has the following built-in objects:
1. Request object
Request indicates the httpservletrequest object. It contains information about browser requests and provides several useful methods for obtaining cookie, header, and session data. The request information of the client is encapsulated in the request object, so that the client can understand the customer's requirements and then respond.
1 object getattribute (string name) returns the property value of the specified attribute. If the property does not exist, null is returned.
2 enumeration getattributenames () returns the enumeration of all available attribute names
3 string getauthtype (); returns the name of the authentication method used to protect the servlet. If not, null is returned.
4 string getcharacterencoding () returns the character encoding method
5 Int getcontentlength () returns the length of the Request body (in bytes). If the length cannot be determined,-1 is returned.
6 string getcontenttype () Get the MIME type of the Request body
7 string getcontentpath () returns the Request Path.
8. Cookie [] getcookies () returns an array of all cookies on the client.
9 enumeration getheadernames () returns a set of names of all HTTP headers.
10 enumeration getheaders (string name) returns a set of all values of the specified HTTP header.
11 string getheader (string name) returns the HTTP header with the specified name.
12 long getdateheader (string name) returns the information of the HTTP header of the data type with the specified name.
13 int getintheader (string name) returns the information of the int Type HTTP header with the specified name.
14 servletinputstream getinputstream () obtains the binary stream of a row in the Request body.
15 locale getlocale () returns the locale object of the current page, which can be set in response.
16 enumeration getlocales () returns the set of all locale objects in the request.
17 string getlocalname () gets the server host name that responds to the request.
18 string getlocaladdr () gets the server address of the Response Request.
19 int getlocalport () gets the server port that responds to the request
20 string getmethod () gets the method (get, post) that the client sends a request to the server ).
21 string getparameter (string name) returns the parameter value of the specified name parameter
22 map getparametermap () This method returns a map object containing all the parameters in the request.
23 enumeration getparameternames () returns a set of all parameters in the request.
24 string [] getparametervalues (string name) returns an array containing all values of the parameter name
25 string getquerystring () returns the parameter string passed by the get method. This method does not parse individual parameters.
26 string getpathinfo () retrieves additional information between servletpath and querystring in the request.
27 string getpathtranslated () returns the actual path of the path information obtained using the getpathinfo () method.
28 string getprotocol () returns the protocol used by the request. It can be http1.1 or http1.0.
29 bufferedreader getreader () returns the reader object corresponding to the input stream of the request. This method and the getinputstream () method can only be called on one page.
30 string getremoteaddr () returns the IP address of the client sending the request.
31 string getremotehost () returns the client host name that sent this request
32 string getremoteuser () returns the user name verified by the client, and null is returned without verification.
33 int getremoteport () returns the client host port that sends the request.
34 string getrealpath (string path) returns the actual path of a virtual path
35 requestdispatcher getrequestdispatcher (string path) generates resources based on the given path and redirects to the adapter object.
36 string getrequestedsessionid () returns the ID of the Request session.
37 string requesturi () returns the client address of the request, but does not include the request parameter string.
38 stringbuffer getrequesturi () returns the server address of the Response Request
39 string getscheme () returns the scheduler name used for the request, such as HTTP. HTTPS and FTP.
40 string getservername () returns the name of the server responding to the request.
41 string getservletpath () obtains the file path of the script file requested by the client.
42 int getserverport () returns the port number used by the server to accept this request
43. Void removeattribute (string name): Delete the attribute of the specified name from the attribute list.
44. Void setattribute (string name, object Value) Add/delete a specified attribute in the attribute list.
45. Void setcharacterencoding (string name) sets the character encoding format of the request.
46. httpsession getsession ();
Httpsession getsession (Boolean create) gets the session. If create is true, create a session without a session.
47. boolean isrequestedsessionidfromcookie () checks whether the request session ID is passed through the cookie.
48. boolean isrequestedsessionidfromurl () check whether the request session ID is passed in through the URL.
49. boolean isrequestedsessionidvalid () check whether the request session ID is still valid.
50. boolean issecure () check whether the request uses a secure link, if https or so.
51. boolean isuserinrole (string role) checks whether the verified user is in the role specified by role.
52. Principal getuserprincipal () returns a java. Security. principal object containing the user's login name.
Member:
String basic_auth = "Basic"
String client_cert_auth = "client_cert"
String digest_auth = "Digest"
String form_auth = "form"
2. Response object
Response indicates the httpservletresponse object. It mainly transmits the processing result of the JSP Container Back to the client.
1 void addcookie (cookie) Add a cookie object to save client information.
2 void adddateheader (string name, long value) to add a date-Type HTTP header information, overwrite the HTTP header information of the same name.
3 void addheader (string name, string value) adds an HTTP header to overwrite the old HTTP header with the same name.
4 void addintheader (string name, int value) adds an integer HTTP header to overwrite the old HTTP header with the same name.
5 Boolean containsheader (string name) determines whether the specified HTTP header exists.
6 string encoderedirecturl (string URL): encode the URL used by sendredirect.
7 string encodeurl (string URL) encodes the URL and returns the URL containing the session ID.
8 void flushbuffer () forces the content of the current buffer to be sent to the client.
9 int getbuffersize () gets the buffer size in KB.
10 string getcharacterencoding () obtains the character encoding format of the response.
11 string getcontenttype () gets the response type.
12 locale getlocale () gets the response locale object.
13 servletoutputstream getoutputstream () returns the output stream object of the client.
14 printwriter getwriter () gets the writer object corresponding to the output stream.
15 Boolean iscommitted () determines whether the server has output data to the client.
16 void reset () clears all content in the buffer.
17 void resetbuffer () indicates all content in the buffer, but the HTTP header and status information are retained.
18 void senderror (int xc, string MSG)
Void senderror (int xc) sends an error, including the status code and error message.
19 void sendredirect (string locationg) sends the response to another location for processing.
20 void setbuffersize (INT size) sets the buffer size in KB.
21 void setcharacterencoding (string charset) sets the character encoding format used by the response.
22 void setcontentlength (INT length) sets the length of the response body.
23 void setcontenttype (string type) sets the response type.
24 void setdateheader (string name, long value) sets the value of the data-Type HTTP header with the specified name.
25 void setheader (string name, string value) sets the HTTP header value of the specified name.
26 void setintheader (string name, int value) sets the HTTP header value of the int type of the specified name.
27 void setstatus (int xc) sets the response status code. The new value overwrites the current value.
Member (HTTP status code ):
Int SC _continue = 100 int SC _switching_protocols = 101
Int SC _ OK = 200 int SC _non_authoritative_information = 203
Int SC _access Ted = 202 int SC _created = 201
Int SC _no_content = 204 int SC _reset_content = 205
Int SC _partial_content = 206 int SC _multiple_choices = 300
Int SC _moved_permanently = 301 int SC _moved_temporarily = 302
Int SC _found = 302 int SC _see_other = 303
Int SC _not_modified = 304 int SC _use_proxy = 305
Int SC _temporary_redirect= 307 int SC _bad_request = 400
Int SC _unauthorized = 401 int SC _payment_required = 402
Int SC _forbidden = 403 int SC _not_found = 404
Int SC _method_not_allowed = 405 int SC _not_acceptable
3. Session Object
Session indicates the javax. servlet. http. httpsession object of a request. It refers to a session between the client and the server, starting from a webapplication that the client connects to the server until the client and the server are disconnected.
1 long getcreationtime () returns the session Creation Time
2 Public String GETID () returns the unique ID number set by the JSP Engine during session creation.
3 long getlastaccessedtime () returns the last client request time in this session
4 int getmaxinactiveinterval () returns the interval between two requests this session is canceled (MS)
5 string [] getvaluenames () returns an array containing all the available attributes of this session.
6 void invalidate () cancels the session and makes the session unavailable
7 Boolean isnew () returns a session created by the server, whether the client has been added
8 void removevalue (string name) deletes the attribute specified in the session.
9 void setmaxinactiveinterval () sets the interval between two requests this session is canceled (MS)
4. Out object
The out object is an instance of javax. jsp. jspwriter. It provides several methods for sending output results to the browser.
1 void clear () clears the buffer, but does not output it to the client.
2 void clearbuffer () clears the current content of the buffer and outputs it to the client.
3 void close () Close the output stream and clear all content.
4 void flush () outputs the data in the buffer.
5 Int getbuffersize () returns the buffer size in bytes. If no buffer is set, the value is 0.
6 int getremaining () returns how much available the buffer is.
7 Boolean isautoflush () indicates whether to automatically clear or throw an exception when the returned buffer is full.
8. Void newline () Outputs A line feed character.
9. Void print (Boolean B) Outputs Data of the specified type to the HTTP stream without line feed.
10. Void println (Boolean B) Outputs Data of the specified type to the HTTP stream and outputs a line break.
11.
Appendable append (char C)
Appendable append (charsequence cxq, int start, int end)
Appendable append (charsequence cxq)
Add a character or an object that implements the charsequence interface to the end of the output stream.
Member:
Int default_buffer = 0-default buffer size
Int no_buffer =-1-whether the writer is in the buffer output status
Int unbounded_buffer =-2-whether to limit the buffer size
5. Page Object
The page object points to the current JSP page itself, a bit like the this pointer in the class. It is an instance of the Java. Lang. Object Class.
1 class getclass returns the class of this object
2 int hashcode () returns the hash code of this object
3 Boolean equals (Object OBJ) determines whether the object is equal to the specified object.
4 void copy (Object OBJ): copy the object to the specified object.
5. Clone () this object.
6 string tostring () converts the object to a string object.
7 void y () Wake up a waiting thread
8 void yyall () Wake up all waiting threads
9 void wait (INT timeout) causes a thread to wait until the timeout ends or is awakened
10 void wait () enables a thread to wait until it is awakened
11 void entermonitor () locks the object
12 Void exitmonitor () locks the object
6. Application Object
Applicaton indicates a javax. servlet. servletcontext object. It shares data between users and stores global variables. It
Starting from the start of the server until the server is closed, this object will exist during this period; this will connect to or from different users
You can perform operations on the same property of the object in the connection between objects. operations on the property of this object anywhere will affect
Access. The startup and shutdown of the server determine the life of the Application object.
1 object getattribute (string name) returns the attribute value to the name
2 enumeration getattributenames () returns the enumeration of all available attribute names
3 void setattribute (string name, object OBJ)
4 void removeattribute (string name) delete a property and its attribute values
5 string getserverinfo () returns the JSP (servlet) engine name and version number.
6 string getrealpath (string path) returns the actual path of a virtual path.
7 servletcontext getcontext (string uripath) returns the Application Object of the specified webapplication.
8 int getmajorversion () returns the maximum servlet API version supported by the server.
9 int getminorversion () returns the maximum servlet API version supported by the server.
10 string getmimetype (string file) returns the MIME type of the specified file
11 URL getresource (string path) returns the URL path of the specified resource (file and directory)
12 inputstream getresourceasstream (string path) returns the input stream of the specified resource
13 requestdispatcher getrequestdispatcher (string uripath) returns the requestdispatcher object of the specified resource
14 servlet getservlet (string name) returns the servlet with the specified name
15 enumeration getservlets () returns the enumeration of all servlets
16 enumeration getservletnames () returns the enumeration of all servlet names
17 void log (string MSG) writes the specified message to the servlet Log File
18 void log (exception, string MSG) writes the stack track and error message of the specified exception to the servlet Log File
19 void log (string MSG, throwable) writes stack tracing and descriptions of throwable exceptions to Servlet's
Log File.
7. Exception object
An exception object is an exception object. When an exception occurs during a page running, this object is generated. If a JSP page needs
If this object is used, you must set iserrorpage to true; otherwise, compilation fails. It is actually a java. Lang. throwable object.
8. pagecontext object
Pagecontext indicates a javax. servlet. jsp. pagecontext object. The pagecontext object provides all the objects and
Namespace access, that is, he can access the session on this page, or take a property value of the application where this page is located.
.
1 jspwriter getout () returns the jspwriter stream (out) in use in the current client response)
2 httpsession getsession () returns the httpsession object (session) on the current page)
3 object getpage () returns the object (PAGE) of the current page)
4 servletrequest getrequest () returns the servletrequest object (request) of the current page)
5 servletresponse getresponse () returns the servletresponse object (response) of the current page)
6 exception getexception () returns the exception object (exception) of the current page)
7 servletconfig getservletconfig () returns the servletconfig object (config) of the current page)
8 servletcontext getservletcontext () returns the servletcontext object (Application) of the current page)
9 void setattribute (string name, object attribute) set attributes and attribute values
10 void setattribute (string name, object OBJ, int scope) set attributes and attribute values within the specified range
11 public object getattribute (string name): Get the attribute value
12 object getattribute (string name, int scope) takes the attribute value within the specified range
13. Search for a public object findattribute (string name) Attribute and return the starting attribute value or null.
14 void removeattribute (string name) delete an attribute
15 void removeattribute (string name, int scope) deletes an attribute within a specified range.
16 int getattributescope (string name) returns the range of an attribute.
17 enumeration getattributenamesinscope (INT scope) return available attribute name enumeration within the specified range
18 void release () releases resources occupied by pagecontext
19 void forward (string relativeurlpath) causes the current page to be re-exported to another page
20 void include (string relativeurlpath) contains another file at the current position
9. config object
Config indicates a javax. servlet. servletconfig object.
The Config object is used by the JSP Engine to transmit information to a servlet during initialization. This information includes the parameters used during servlet initialization.
Number (consisting of attribute names and attribute values) and server-related information (passing a servletcontext object .)
1 servletcontext getservletcontext () returns the servletcontext object containing server-related information
2 string getinitparameter (string name) returns the value of the initialization parameter.
3 enumeration getinitparameternames () returns the enumeration of all parameters required for servlet initialization.