File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes communication Between two servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "communication Between two servlets" Watch "communication Between two servlets" New topic
Author

communication Between two servlets

abinash das
Ranch Hand

Joined: Apr 26, 2008
Posts: 52
How can i pass some value from a servlet to a JSP if the request dispatch mode is
response.sendRedirect.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

You can add parameters to the url that you give in the sendRedirect method like this

response.sendRedirect("/myPage.jsp?param="+myParam);

Or you can set the value in a session attribute and retrieve it in the other servlet but for that you'll have to encode the redirect url with the session id

response.sendRedirect(reponse.encodeRedirectURL("/myPage.jsp"));


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
abinash das
Ranch Hand

Joined: Apr 26, 2008
Posts: 52


In the given techinque

i,e response.sendRedirect(reponse.encodeRedirectURL("/myPage.jsp"));

how can i pass values to myPage.jsp.
maens how to define and set values and how to get these values at myPage.jsp
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
When redirecting, pass it as request parameters (visible in URL).
When forwarding, pass it as request attributes (hidden from URL).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: communication Between two servlets
 
Similar Threads
Capturing Form Data
WA #1.....word association
Downloading HTML page
Export in Excel
Un-downloadable Applets