[JSP learning notes] Passing JSP page Parameters

Source: Internet
Author: User

(1) Add
For example, <a href = "thexuan. jsp? Action = transparams & detail = directe ") directly pass the parameter/A>
When using response. sendredirect for page redirection, you can also use the following code:
Response. sendredirect ("thexuan. jsp? Action = transparams & detail = directe "), which can be obtained by request. getparameter (name ).
  
(2) JSP: Param
It allows you to pass parameters to the include page on the home page, as follows:
<JSP: Include page = "relative URL">
<JSP: Param name = "Param name" value = "paramvalue"/>
</Jsp: Include>
You can also pass parameters when using the JSP: forward action for page Jump, as follows:
<JSP: Forward page = "relative URL">
<JSP: Param name = "paramname" value = "paramvalue"/>
</Jsp: Forward> in this way, parameters can be obtained through request. getparameter (name), which is the same as common form parameters.
(3) set the session and request
The displayed parameters are placed in the session and request to pass the parameters.
Session. setattribute (name, value );
Request. setattribute (name, value)
Take the parameter value = (value classname) Session. getattribute (name );
Value = (value classname) request. getattribute (name );
You must have noticed that the type conversion is performed when the parameter is obtained, because the attributes of the objects placed in the session and request are treated as Java. lang. if the object type is not converted, The classcastexception exception is reported when the value is directly paid.

 

 

Kay's word: I tried it (3). It seems that the request cannot be passed between JSP, because the session changes? The session can be used for another scenario.

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.