① Out-javax. servlet. jsp. jspwriter
The out object is used to output the result to the webpage.
Method:
1. Void clear ();
Clears the content of the output buffer but does not output it to the client.
2. Void clearbuffer ();
Clear the content of the output buffer and output it to the client.
3. Void close ();
Close the output stream and clear all content.
4. Void flush ();
Output Data in the buffer.
5. Int getbuffersize ();
Obtains the current buffer size in KB.
6. Int getremaining ();
Obtains the unoccupied space in the buffer in KB.
7. boolean isautoflush ();
Whether to automatically refresh the buffer.
8. Void newline ();
Output A line feed character.
9. Void print (Boolean B );
Void print (char C );
Void print (char [] S );
Void print (double D );
Void print (float F );
Void print (int I );
Void print (long L );
Void print (Object OBJ );
Void print (string S );
Outputs Data of the specified type to the HTTP stream without line breaks.
10. Void println (Boolean B );
Void println (char C );
Void println (char [] S );
Void println (double D );
Void println (float F );
Void println (int I );
Void println (long L );
Void println (Object OBJ );
Void println (string S );
Output data of the specified type to the HTTP stream and 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
② Request-javax. servlet. http. httpservletrequest
The request object contains information about all requests, such as the request source, header, cookies, and request-related parameter values.
Method:
1. Object getattribute (string name );
Returns the property value specified by name. If the property does not exist, null is returned.
2. Enumeration getattributenames ();
Returns a set of all attribute names of the request object.
3. String getauthtype ();
Returns the name of the authentication method used to protect the servlet. If not, null is returned.
4. String getcharacterencoding ();
The character encoding method in the return request, which can be set in the response object.
5. Int getcontentlength ();
Returns the length of the Request body. If the length cannot be determined,-1 is returned. You can set it in response.
6. String getcontenttype ();
Return the content type defined in response.
7. String getcontentpath ();
The path of the returned request.
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 of the specified name.
12. Long getdateheader (string name );
Returns the information of the data-Type HTTP header with the specified name.
13. Int getintheader (string name );
Returns the int Type HTTP header of the specified name.
14. servletinputstream getinputstream ();
Returns the input stream of the request.
15. locale getlocale ();
Return 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 ();
Obtain the server host name that responds to the request.
18. String getlocaladdr ();
Obtain the server address that responds to the request.
19. Int getlocalport ();
Obtain the server port in response to the request
20. String getmethod ();
Obtain the methods (get and post) that the client sends to the server ).
21. String getparameter (string name );
Obtain the parameter value sent from the client to the server.
22. Map getparametermap ();
This method returns a map object containing all parameters in the request.
23. Enumeration getparameternames ();
Returns the set of all parameters in the request.
24. String [] getparametervalues (string name );
Obtain all values of the specified parameter in the request.
25. String getquerystring ();
Returns the parameter string passed by the get method. This method does not parse individual parameters.
26. String getpathinfo ();
Retrieve the additional information in the request between servletpath and querystring.
27. String getpathtranslated ();
Returns the actual path of the path information obtained using the getpathinfo () method.
28. String getprotocol ();
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 ();
Obtain the IP address of the client sending the request.
31. String getremotehost ();
Obtain the client host name that sends the request
32. String getremoteuser ();
Returns the user name verified by the client. If the user name is not verified, null is returned.
33. Int getremoteport ();
Returns the host port of the client sending the request.
34. String getrealpath (string path );
Returns the physical path of the given virtual path.
35. requestdispatcher getrequestdispatcher (string path );
Generate a resource based on the given path to process the adapter object.
36. String getrequestedsessionid ();
The identifier of the Request session.
37. String requesturi ();
Returns the client address that sends the request, but does not include the request parameter string.
38. stringbuffer getrequesturi ();
Returns the server address of the Response Request.
39. String getscheme ();
Obtain the protocol name. The default value is HTTP.
40. String getservername ();
The name of the server that responds to the request.
41. String getservletpath ();
Obtain the path of the script file requested by the client.
42. Int getserverport ();
Obtain the server-side host port number that responds to the request.
43. Void removeattribute (string name );
Delete the attribute of the specified name in the attribute list.
44. Void setattribute (string name, object value );
Add/delete a specified property in the property list.
45. Void setcharacterencoding (string name );
Set the character encoding format of the request.
46. httpsession getsession ();
Httpsession getsession (Boolean create );
Obtain the session. If create is true, create a session without a session.
47. boolean isrequestedsessionidfromcookie ();
Check whether the request session ID is passed in through cookies.
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, such as HTTPS.
51. boolean isuserinrole (string role );
Check 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 "-
③ Response-javax. servlet. http. httpservletresponse
The response object mainly transmits the results processed by the JSP Container Back to the client.
Method:
1. Void addcookie (cookie );
Add a cookie object to save client information.
2. Void adddateheader (string name, long value );
Add an HTTP header of the date type to overwrite the HTTP header of the same name.
3. Void addheader (string name, string value );
Add an HTTP header to overwrite the old HTTP header with the same name.
4. Void addintheader (string name, int value );
Add 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 the sendredirect () method.
7. String encodeurl (string URL );
Encode the URL and return 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 ();
Obtain the buffer size in KB.
10. String getcharacterencoding ();
Obtains the character encoding format of the response.
11. String getcontenttype ();
Obtain the response type.
12. locale getlocale ();
Obtain the response locale object.
13. servletoutputstream getoutputstream ();
Return the output stream object of the client.
14. printwriter getwriter ();
Gets the writer object corresponding to the output stream.
15. boolean iscommitted ();
Determine whether the server has output data to the client.
16. Void reset ();
Clears all content in the buffer.
17. Void resetbuffer ();
Buffer, but the HTTP header and status information are retained.
18. Void senderror (int xc, string MSG );
Void senderror (int xc );
Sending error, including status code and error message.
19. Void sendredirect (string locationg );
Send the response to another location for processing.
20. Void setbuffersize (INT size );
Set the buffer size in KB.
21. Void setcharacterencoding (string charset );
Set the character encoding format used by the response.
22. Void setcontentlength (INT length );
Set the length of the response body.
23. Void setcontenttype (string type );
Set the response type.
24. Void setdateheader (string name, long value );
Set the value of the data-Type HTTP header with the specified name.
25. Void setheader (string name, string value );
Set the HTTP header value of the specified name.
26. Void setintheader (string name, int value );
Set the int Type HTTP header value of the specified name.
27. Void setstatus (int xc );
Set 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 = 406
Int SC _proxy_authentication_required= 407 int SC _request_timeout = 408
Int SC _conflict = 409 int SC _gone = 410
Int SC _length_required = 411 int SC _precondition_failed = 412
Int SC _request_entity_too_large = 413 int SC _request_uri_too_long = 414
Int SC _unsupported_media_type = 415 int SC _requested_range_not_satisfiable = 416
Int SC _expectation_failed = 417 int SC _internal_server_error = 500
Int SC _not_implemented = 501 int SC _bad_gateway = 502
Int SC _service_unavailable = 503 int SC _gateway_timeout = 504
Int SC _http_version_not_supported = 505
④ Session-javax. servlet. http. httpsession
Session Object indicates the session Status of individual users, which is used to identify each user.
Method:
1. Object getattribute (string name );
Obtains the session attribute value associated with the specified name.
2. Enumeration getattributenames ();
Obtains the set of all attributes in a session.
3. Long getcreationtime ();
Returns the creation time of the session. The minimum unit is 1‰ seconds.
4. String GETID ();
Obtains the session ID.
5. Long getlastaccessedtime ();
Returns the last access time of the client associated with the current session, measured from, in milliseconds.
6. Int getmaxinactiveinterval (INT interval );
Total time returned, in seconds, indicates the effective time of the session (the time when the session is not active ). -1 indicates that it never expires.
7. servletcontext getservletcontext ();
Returns an instance of the servletcontext object corresponding to the JSP page.
8. httpsessioncontext getsessioncontext ();
9. Object getvalue (string name );
It is not recommended to obtain the session variable value of the specified name.
10. String [] getvaluenames ();
It is not recommended to obtain the set of names of all session variables.
11. Void invalidate ();
Destroy this session object.
12. boolean isnew ();
Checks whether a session is generated by the server, but is not used by the client.
13. Void pubvalue (string name, object value );
It is not recommended to add a session variable.
14. Void removevalue (string name );
It is not recommended to remove the value of a session variable.
15. Void setattribute (string name, string value );
Sets the session attribute value of the specified name.
16. Void setmaxinactiveinterval (INT interval );
Set the session validity period.
17. Void removeattribute (string name );
Removes the session attribute of the specified name.
⑤ Pagecontext-javax. servlet. jsp. pagecontext
The pagecontext object stores information about the JSP page, such as attributes and built-in objects.
Method:
1. Void setattribute (string name, object value, int scope );
Void setattribute (string name, object value );
Set attributes within the specified sharing range.
2. Object getattribute (string name, int scope );
Object getattribute (string name );
Obtains the attribute value named name in the specified shared range.
3. Object findattribute (string name );
Search for named properties by PAGE, request, session, and application sharing range.
4. Void removeattribute (string name, int scope );
Void removeattribute (string name );
Removes the attribute of the specified name and shared range.
5. Void forward (string URL );
Navigate to the specified URL.
6. Enumeration getattributenamesscope (INT scope );
Obtains a set of all attribute names within a specified shared range.
7. Int getattributescope (string name );
Obtains the shared range of a specified attribute.
8. errordata geterrordate ();
Get the errordata object of the page.
9. Exception getexception ();
Get the exception object of the page.
10. expressionevaluator getexpressionevaluator ();
Obtain the expressionevaluator object of the page.
11. jspwriter getout ();
Obtain the out object of the page.
12. Object getpage ();
Obtain the Page Object of the page.
13. servletrequest getrequest ();
Obtain the request object of the page.
14. servletresponse getresponse ();
Obtain the response object of the page.
15. servletconfig getconfig ();
Get the config object of the page.
16. servletcontext getservletcontext ();
Obtain the servletcontext object of the page.
17. httpsession getsession ();
Obtain the session object of the page.
18. variableresolver getvariableresolver ();
Obtain the variableresolver object of the page.
19. Void include (string URL, Boolean flush );
Void include (string URL );
Contains other resources and specifies whether to automatically refresh.
20. Void release ();
Reset the internal status of pagecontext to release all internal references.
21. Void initialize (servlet, servletrequest request, servletresponse response,
String errorpageurl, Boolean needsession, int buffersize, Boolean autoflush );
Initialize the uninitialized pagecontext object.
22. bodycontext pushbody ();
Bodycontext pushbody (writer );
Save the current out object and update the out object in the page range of pagecontext.
23. jspwrite popbody ();
Retrieve the out object saved by the pushbody () method.
24. Void handlepageexception (exception E );
Void handlepageexception (thrwoable t );
Member:
Int page_scope = 1-page sharing range
Int request_scope = 2-request sharing range
Int session_scope = 3-session sharing range
Int application_scope = 4-application sharing range
String page = "javax. servlet. jsp. jsppage"
String pagecontext = "javax. servlet. jsp. jsppagecontext"
String request = "javax. servlet. jsp. jsprequest"
String response = "javax. servlet. jsp. jspresponse"
String Config = "javax. servlet. jsp. jspconfig"
String session = "javax. servlet. jsp. jspsession"
String out = "javax. servlet. jsp. jspout"
String application = "javax. servlet. jsp. jspapplication"
String exception = "javax. servlet. jsp. jspexception"
⑥ Application-javax. servlet. servletcontext
The main function of application is to get or change servlet settings.
Method:
1. Object getattribute (string name );
Returns the application attribute specified by name.
2. Enumeration getattributes ();
Returns all application attributes.
3. servletcontext getcontext (string uripath );
Obtains the servletcontext object of the current application.
4. String getinitparameter (string name );
Returns the initial value of the application attribute specified by name.
5. Enumeration getinitparameters ();
Returns the set of initial values of all application attributes.
6. Int getmajorversion ();
Returns the version number of the servlet API supported by the servlet container.
7. String getmimetype (string file );
Returns the type of the specified file. returns NULL for the unknown type. It is generally "text/html" and "image/GIF ".
8. Int getminorversion ();
Return the minor version number of the servlet API supported by the servlet container.
9. String getrealpath (string path );
Returns the physical path corresponding to the given virtual path.
10. requestdispatcher getnameddispatcher (string name );
Returns an instance of the requestdispatcher object for the servlet object with the specified name.
11. requestdispatcher getrequestdispatcher (string path );
Returns an instance of a requestdispatcher object.
12. url getresource (string path );
Returns a URL object instance corresponding to the specified resource path. The parameter must start.
13. inputstream getresourceasstream (string path );
Returns an inputstream object instance of a resource at the specified position of the path.
14. Set getresourcepaths (string path );
Returns the set of all resource paths stored in the Web-app.
15. String getserverinfo ();
Obtain the application server version.
16. servlet getservlet (string name );
Search for the servlet with the specified name in servletcontext.
17. Enumeration getservlets ();
Returns the set of all servlets in the servletcontext.
18. String getservletcontextname ();
Returns the name of the Web application.
19. Enumeration getservletcontextnames ();
Returns the name set of all servlets in the servletcontext.
20. Void log (exception ex, string MSG );
Void log (string MSG, throwable t );
Void log (string MSG );
Write the specified information to the servlet log file.
21. Void removeattribute (string name );
Removes the application attribute of the specified name.
22. Void setattribute (string name, object value );
Set the value of the specified application attribute.
7. config-javax. servlet. servletconfig
The Config object is used to store the initial servlet data structure.
Method:
1. String getinitparameter (string name );
Returns the value of the prompt parameter named name.
2. Enumeration getinitparameters ();
Returns the names of all the prompt parameters in the JSP.
3. servletcontext getcontext ();
The servlet context of the performer.
4. String getservletname ();
The name of the servlet.
Except exception-java. Lang. throwable
Error object. The exception object can be used on this page only after iserrorpage = "true" is specified in the page command of the JSP page.
Method:
1. throwable fillinstacktrace ();
Record the current stack information to the exception object.
2. String getlocalizedmessage ();
Obtain the error message of the local language.
3. String getmessage ()
Get error message.
4. stacktrackelement [] getstacktrace ();
Return the call stack track information recorded in the object.
5. throwable initcause (throwable cause );
Nest another exception object into the current exception object.
6. throwable getcause ();
Retrieve exceptions nested in the current exception object.
7. Void printstacktrace ();
Void printstacktrace (printstream S );
Void printstacktrace (printwriter S );
Print throwable and its call stack trace information.
8. Void setstacktrace (stacktraceelement [] stacktrace)
Sets the call stack trace information of an object.
Dynamic page-javax. servlet. jsp. httpjsppage
The page object represents the JSP object itself, or the compiled servlet object,
You can use (javax. servlet. jsp. httpjsppage) page to obtain its methods and attributes.