JSP interview questions and answers

Source: Internet
Author: User
Tags flush

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

A: JSP has the following nine basic built-in components (which can 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 <% @ shortdefile = "shortded.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
3 <jsp: forwardpagejsp: forwardpage = "nextpage. jsp"/> The former page does not go to the page referred to by include, but only displays the results of this 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 (such as cookies and header information) for setting the response to the browser. The out object is javax. jsp. an example of JspWriter, and provides several methods for you to send the output results back 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 the user's state information applicaton, indicating a javax. servle. ServletContext object. This helps to find information about the servlet engine and servlet environment. config represents 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.

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