Passing Parameters to Another JSP Page

An include action (see Including a File in a JSP Page) executes the included JSP page and appends the generated output onto its own output stream. Request parameters parsed from the URL's query string are available not only to the main JSP page but to all included JSP pages as well. It is possible to temporarily override a request parameter or to temporarily introduce a new request parameter when calling a JSP page. This is done by using the jsp:param action.

In this example, param1 is specified in the query string and is automatically made available to the callee JSP page. param2 is also specified in the query string but is overridden by the caller. Notice that param2 reverts to its original value after the call. param3 is a new request parameter created by the caller. Notice that param3 is only available to the callee and when the callee returns, param3 no longer exists. Here is the caller JSP page:

<html> <head></head> <body> <jsp:include page="callee.jsp" /> <jsp:param name="param2" value="value2" /> <jsp:param name="param3" value="value3" /> </jsp:include> Caller: param1: <%= request.getParameter("param1") %> param2: <%= request.getParameter("param2") %> param3: <%= request.getParameter("param3") %> </body> </html>
Here is the JSP page being called:
Callee: param1: <%= request.getParameter("param1") %> param2: <%= request.getParameter("param2") %> param3: <%= request.getParameter("param3") %>
If the example is called with the URL:
http://hostname.com?param1=a&param2=b
the output would be:
Callee: param1: a param2: value2 param3: value3 Caller: param1: a param2: b param3: null

Comments

15 Jan 2010 - 2:20am by ahmettolga (not verified)

it clearifies an important point, thanks.

24 Jul 2010 - 7:54pm by Anonymous (not verified)

hi..
can you help me..
want to take parameter from action form..
example:

kirim

action="tangkep.jsp?aa=qqqqqq"
my question is..
how to take parameter from
action="tangkep.jsp?aa=qqqq"
aa=qqqq
how to take it. .
please help..

27 Jul 2010 - 6:13am by Anonymous (not verified)

should be

(no closing slash at the end)

27 Jul 2010 - 6:14am by Anonymous (not verified)

meh my input was messe dup in previous post

Using [ instead of < in hope to get it trhough.

[jsp:include page="callee.jsp" /]
should be
[jsp:include page="callee.jsp"]
(no closing slash at the end)

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.