Basic syntax of JSP--Request forwarding and redirect __js

Source: Internet
Author: User
Basic syntax for JSP:
1. JSP expression: Provides a way to directly calculate the Java variable or expression to the client's simplified way, it will output the variable
Or an expression is encapsulated directly in the <%=%>.


2. Methods:
Object setattribute (String name): Gets the specified property
Enumertion getattributenames (): Gets the names of all the properties of the enumeration object
RemoveAttribute (String name): Removing the specified property
void setattribute (String name,object o): Setting properties

The following--domain objects--all have these methods:
PageContext: The scope is limited to the current JSP page.
Request: The scope of the property is limited to the same request.
Session: Scope Limited to one conversation (browser open until shutdown is called a session)
Application: Scoped to the current Web application, is the scope of the largest range of properties.
Called a domain object

***
Redirection and forwarding of requests:

Forwarded for Request: Request.getrequestdispatcher ("/c.jsp"). Forward (request, response);
Redirect: Response.sendredirect ("c.jsp");

1. Essential difference:

1 The requested forwarding only makes one request, and the redirect makes two requests.


2 Forwarding of requests: can only be forwarded to the root directory of the current Web application.
Redirect: Can be directed to any resource.

3 The requested forwarding:/represents the current Web application's root directory.
Redirect:/represents the root directory of the current Web site.

4 Request Forwarding: In the final servlet, the request object and the relay request are the same object.
Redirect: In the final servlet, the request object and the transfer request are not the same object
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.