• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with sendRedirect()

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have one index page in my site where the user has to verify himself with name and password, then this information is passed to a servlet which matches the same against a database. From here I want to transfer the request to a JSP with response.sendRedirect() method. The JSP page is called but request parameters are not available here. How caN i make request parameters available in this page also?
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to do the following:
(1). In servlet:
----- request.setAttribute("YourParameter");
--- getServletConfig().getServletContext().getRequestDispatcher("YourJspPageReativeURL").forward(req,res);
(2). In JSP:
String parameter = request.getAttribute("YourParameter");
......
I hope it will help you!
Good Luck
 
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the code :
<%
response.sendRedirect(" the iurl where you wanna go");
%>
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Raghav, I think you missed the point -- request parameters normally don't survive a redirect. Of course you can add parameters to a redirect, as to any request:
response.sendRedirect("http://url/page.jsp?parameter=blah");
But in this case it looks like a forward is more appropriate.
- Peter
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When we uses sendredirect then it does not passe the values to next page.For this either u can use forward or sendRedirect("uri+querystring)
Means by only querystring u can pass the values in sendRedirect
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic