(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. JSP Study Notes (6) ----- pass the parameter [big, medium, and small] [print] [add to favorites] [close] [add to Sina Vivi] [add to favorites to 365key] between multiple JSP pages browse font size: Date: popularity:
9325 Source: csdn
Passing parameters between multiple JSP pages
1. How to pass parameters between multiple JSP pages? Use the JSP built-in scope object session. Using its two methods setattribute (), getattribute ()
2. The following example implements the function of passing parameters of the first JSP page to the third page.
3. The Code is as follows: 1.jsp
<HTML>
<Form method = get action = 2.jsp>
What's your name <input type = text name = username>
<Input type = submit value = submit>
</Form>
</Html>
4. 2.jsp
<HTML>
<Form method = post action = "3.jsp? Pass = 11 ">
<%
String name = request. getparameter ("username ");
Session. setattribute ("username", name );
%>
Your name is: <% = request. getparameter ("username") %>
<Br> what's your holobby <input type = text name = holobby>
<Input type = submit value = submit>
</Form>
</Html>
5. 3.jsp
<HTML>
Your name is: <% = session. getattribute ("username") %>
<Br>
Your holobby is: <% = request. getparameter ("holobby") %>
<Br>
Your password is: <% = request. getparameter ("pass") %>
<Br>
</Form>
</Html>