Six typical JSP questions and explanations

Source: Internet
Author: User

JSP Question 1. What built-in objects does jsp have? What are their roles?

A: JSP has the following nine basic built-in components that correspond to the six internal components of ASP ):

Request client request, which contains parameters from the GET/POST request

Response returned from the response webpage to the client

The pageContext page is managed here.

Session-related session Period

What is being executed by applicationservlet

Out is used to send response output.

Configservlet framework

PageJSP page itself

Exception for the error webpage, exceptions not captured

JSP Question 2. What actions does jsp have? What are their roles?

A: JSP has the following 6 basic actions:

Jsp: include: Introduce a file when the page is requested.

Jsp: useBean: Find or instantiate a JavaBean.

Jsp: setProperty: Set attributes of JavaBean.

Jsp: getProperty: outputs the attributes of a JavaBean.

Jsp: forward: Transfers requests to a new page.

Jsp: plugin: generate the OBJECT or EMBED tag for the Java Plug-in based on the browser type

JSP Question 3. Difference between forward and redirect

A: forward is the server that requests resources. The server directly accesses the URL of the target address, reads the response content of the URL, and sends the content to the browser, the browser does not know where the content sent by the server comes from, so its address bar is still the original address.
Redirect means that the server sends a status code based on logic to tell the browser to request the address again. Generally, the browser will re-request the address with all the parameters just requested, so the session and request parameters can be obtained.

JSP Question 4. What is the difference between dynamic and static INCLUDE in JSP?

A: Dynamic INCLUDE is implemented using jsp: include actions <jsp: includepage = "included. jsp "flush =" true "/> always checks for changes in the contained files. It is suitable for inclusion of dynamic pages and can be implemented using the INCLUDE pseudo code with static include parameters, does not check the changes of the contained files, applicable to include static pages

  1. <%@includefile="included.htm"%> 

JSP Question 5. What are the two jump methods? What is the difference?

A: There are two types:

  1. <jsp:includepagejsp:includepage="included.jsp"flush="true"> 
  2. <jsp:forwardpagejsp:forwardpage="nextpage.jsp"/> 

The former page does not switch to the page referred to by include, but only displays the results of the page. The home page is still the original page. It will return after execution, which is equivalent to a function call. In addition, parameters can be included. The latter is completely redirected to the new page and will not be returned. It is equivalent to a goto statement.

JSP Question 6. built-in JSP objects and Methods

A: request indicates the HttpServletRequest object. It contains information about browser requests and provides several useful methods for obtaining cookie, header, and session data.

Response indicates the HttpServletResponse object, and provides several methods for setting the response to the browser, such as cookies and header information)
The out object is an instance of javax. jsp. JspWriter. It provides several methods for sending output results to the browser.

PageContext indicates a javax. servlet. jsp. PageContext object. It is used to facilitate access to various namespaces and servlet-Related Object APIs, and encapsulates common servlet-related functions.

Session indicates the javax. servlet. http. HttpSession object of a request. Session can store user status information
Applicaton indicates a javax. servle. ServletContext object. This helps you find information about the servlet engine and servlet environment.
Config indicates a javax. servlet. ServletConfig object. This object is used to access the initialization parameters of the servlet instance.
Page indicates a servlet instance generated from the page.

  1. JDK installation and Tomcat configuration for JSP environment setup
  2. Discussion on how to implement the componentization of JSP image uploading
  3. Introduction to using jspsmart for file upload and download
  4. Use JSP pages to generate PDF reports
  5. Step for customizing JSP labels

Related Article

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: 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.