-
Pass parameters from servlet to jsp using the url
Hi i have a servlet that passes control to a jsp this way:
String url = "/test.jsp?code=1&msg=" + URLEncoder.encode("foo message");
System.out.println(url);
RequestDispatcher rd = request.getRequestDispatcher(url);
rd.forward(request,response);
Doing that way test.jsp doesn't receive msg parameter, and in explorer's navigation bar this url can be seen:
http://myserver/test.jsp?code=1&msg=foo+message
it seems that the RequestDispatcher turns & into & and the url in the standard output (System.out) is
/test.jsp?code=1&msg=foo+message
How can i avoid this behaviour?
Thnx.
-
sendRedirect
Try:
response.sendRedirect(url).
JavaDoc
Sharbov.
-
Don't want to do so.
It implies that the query has to go back client and return to the server. I don't want't to do so
I want forward to work. I know other workarround is to put the parameters in the request scope
by using request.setAttribute, and reading them using request.getAttribute in test.jsp, but i have a large number of jsp pages and i don't want to do this chage.
Any other hint?
Thnx.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks