File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes sending parameters through redirecting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "sending parameters through redirecting" Watch "sending parameters through redirecting" New topic

sending parameters through redirecting

sachin dabhade
Ranch Hand

Joined: Mar 10, 2001
Posts: 73
i am redirecting my page using following command from my jsp
out.println("<meta http-equiv=\"refresh\" content=\"2;url=login.jsp\">")
i want to know how can i send the parameters from my original jsp to the one i am redirecting.
i.e i want to send parameters like user id and password to
login.jsp from signup.jsp
my page is like
signup.jsp is generating a dynamic page for thanking and after 2 seconds i want to redirect the page to login.jsp where i want to user parameters like user id and password.
thanks in advance

Cynthia Yao
Ranch Hand

Joined: Nov 06, 2000
Posts: 92
Why don't you put those valuable into session, use session.setAttribute("name", value)
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi Sachin,
If you are looking to redirect, using URLWriting, you can do it by using encodeRedirectURL(), and sendRedirect() methods of the HttpServletResponse class.
Alternatively you can use the RequestDispatcher class and use the forward() method of this class.
In either case, you may append the parameters to the URL after the "?" e.g. http://localhost:8080/Signup.jsp?username=xxxx&password=xxxx.
Just remember that in both the cases you would need to use the http method=POST (I am not very sure with the RequestDispatcher case, please confirm and post the message here if you try it!!)
Hope this helps,

Sandeep Desai

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
Sean MacLean
Ranch Hand

Joined: Nov 07, 2000
Posts: 621
I would recommend using the res.forward() solution since it simply passes along the original request and headers to the next in line.
I agree. Here's the link:
subject: sending parameters through redirecting
It's not a secret anymore!