JSP Exception Handling and some advanced topics

Source: Internet
Author: User

Exception Handling

1. runtime exception
A: 1) An error is returned when a program is running;

2) can be referenced by a fixed exception object;

3) You can create an exception reference or generate a JSP page to display the exception information to the user.

2. Create an exception tracking solution

Answer: 1) Each JSP page contains the name of the exception page to be created;

2) create an exception page;

3. Exception Handling on the JSP page

Answer: 1) print the Exception name;

2) print the list of all errors in the current error stream;

3) print the detailed description of the Error

More advanced topics

1. internally recognized objects in JSP

Answer: Name type comment and Range
Request javax. servlet. http. HttpServletRequest request
Response javax. servlet. http. HttpServletResponse response
PageContext javax. servlet. jsp. PageContext page
Session javax. servlet. http. HttpSession session
Application javax. servlet. ServletContext

Out javax. servlet. jsp. JspWriter output stream

Config javax. servlet. ServletConfig

Page javax. lang. Object page
Exception java. lang. Throwable page

2. request of default object)

A: The request from the client is encapsulated:

Method: 1) getCookies: Obtain the Cookie array;
2) getMethod: return the form of the request (GET/POST );
3) getParameterNames: returns the enumeration of object names in FORM;
4) getParameter: returns the object Value of the specified name;
5) getParametervalues: returns an array of object values with the specified name;
6) setAttribute: Set attributes;
7) getAttribute: returns the property value;
GetAttributeNames: returns the enumeration of attribute names.

3. out of default object

A: an instance of JSPWriter used to send a response to the client.

Method: 1) print (String)/println (String)

2) print (int)/println (int)

3) flush ()

4. exception of default object

Answer: 1) an exception instance is used for an exception object;

2) The error page contains the attribute isErrorPage = "true" in the page command ";

3) method: getMessage ()/printStackTrace ()/toString ()

5. Default object session

Answer: 1) an instance of HttpSession is used to maintain the status of a session.

2) method: getAttribute ()

SetAttribute ()

RemoveAttribute ()

GetAttributeNames ()

6. application of default object

Answer: 1) an instance of ServletContext is used to maintain the application state.

2) method: getAttribute ()

SetAttribute ()

GetInitParameter ()

GetServletInfo ()

3) The application has a much larger scope than the session. One session is associated with one client, while the application maintains the State for all clients.

  1. Several simple and effective methods for improving Jsp skills
  2. Seven Tips for improving JSP page response speed
  3. Seven Practical Methods for Improving JSP applications

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.