![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e1055. Passing Parameters to Another JSP PageAninclude action (see e1054 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, <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¶m2=bthe output would be: Callee: param1: a param2: value2 param3: value3 Caller: param1: a param2: b param3: null
e1054. Including a File in a JSP Page e1056. Using a Bean in a JSP Page
© 2002 Addison-Wesley. |