This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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 ]
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