Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirecting a servlet to a jsp with parameters

Status
Not open for further replies.

orlandoj

Programmer
Feb 10, 2003
27
US
Hey all,

I was wondering how I can send parameters from a servlet to a jsp.

I have this line in the body of my doPost method in my servlet:

response.sendRedirect("/index.jsp");

and, was wondering how I could send a parameter 'url' with the value 'test', without merely just doing:

response.sendRedirect("/index.jsp?url=test");


Thanks,
-Jamie
 
Don't redirect. It is not efficient since it causes a round trip. Do a forward(), see javax.servlet.RequestDispatcher.forward()

-pete
[sub]I just can't seem to get back my IntelliSense[/sub]
 
I've actually looked into both methods, but I decided on the sendRedirect method, because I'm forwarding to a page outside my web-container. Is there any way to send parameters without sending them in the URL?

Thanks,
-Jamie
 
Not for a Redirect. An alternative would be to use client side script and a form submit from the pages onload event.

-pete
[sub]I just can't seem to get back my IntelliSense[/sub]
 
That's a shame. Oh well...thanks so much for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top