aspose file tools*
The moose likes JSP and the fly likes JSP : PARAMS action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP : PARAMS action" Watch "JSP : PARAMS action" New topic
Author

JSP : PARAMS action

Jaggi Kunal
Ranch Hand

Joined: Jan 21, 2003
Posts: 45
I want to retrieve Parameters in a JSP page which are set by another JSP page.
Following are the two code snippets :
<%-- Param1.jsp --%>
<HTML>
<HEAD><HEAD>
<BODY>
<jsp arams>
<jsp aram name="name" value="Yash" />
<jsp aram name="age" value="23" />
<jsp aram name="eyes" value="black" />
</jsp arams>
<A HREF="/Param2.jsp">Click Here</A>
</BODY>
</HTML>
<%-- Param2.jsp --%>
<HTML>
<HEAD><HEAD>
<BODY>
<%
out.println("<b>"+request.getParameter("name")+"</b>");
out.println("<b>"+request.getParameter("age")+"</b>");
out.println("<b>"+request.getParameter("eyes")+"</b>");
%>
</BODY>
</HTML>
I am getting a compilation error when I access Param1.jsp using http://localhost:8080/Para1.jsp. I am using Tomcat 4.1.12.

Regards,
Kunal Jaggi
SCJP
[ April 01, 2003: Message edited by: Jaggi Kunal ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

Do you not think that it might be a tad more useful to actually post the compilation error that you are getting?
Also, if you want to pass request parameters to the next request, you'll either need to encode them as part of the URL (on the the query string), or create a form in which they are posted using hidden parameters.
hth,
bear
[ April 01, 2003: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mark Bensing
Ranch Hand

Joined: Mar 09, 2003
Posts: 40
To expand on what Bear has said, there is no <jsp:params> action in JSP. <jsp:param> can be used within the <jsp:include> and <jsp:forward> actions to add parameters to the request as follows:

Mark
[ April 01, 2003: Message edited by: Mark Bensing ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

Mark is correct on that. I missed the <jsp:params> as the smiley faces got in the way (you do know you can turn those off when posting code, no?).
And that will work fine to include a JSP in another. To pass along a request parameter to a completely separate request however, you are going to have to bite the bullet and generate a URL complete with the parameters in the query string (don't forget to URL-encode the values), or do the hidden form thing.
hth further,
bear
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP : PARAMS action