• 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

Pass parameters with response.sendRedirect

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have website A and website B, both are of the same company. Users of website A can currently login to website A only from website A. Now, we are developing a feature wherein users will be able to login from the login page of website B also. When users try to login from website B, we first validate the user using a web service and if the user is authentic, we should redirect him/her to website A along with a token which would be evaluated by website A and would let the user directly login.

I use response.sendRedirect("http://websiteA?tokenID=12345");

Everything goes as it should except that the parameter token ID is not passed to website A always. To be more precise, it is present in the JSP page in alternate runs. If I close the browser and open it again, the parameter would not be there. But if I run it again, it would be there. I know it has got to do something with response.sendRedirect, but I haven't been able to find an alternate to this.

Please note that the URL will be absolute since both websites are in different servers altogether.

This is a very urgent requirement and any help would be very much appreciated.

Thanks!
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I think you can use JspForward instead of response.redirect.

Here is the syntax for the jsp:forward

<jsp:forward page={"URL" } >
<jsp:param name="parameterName"
value="{parameterValue }" />
</jsp:forward>

One disadvantage is that the url will be same once you forward it to another page (URL of the forward page won't be there)
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Everything goes as it should except that the parameter token ID is not passed to website A always. To be more precise, it is present in the JSP page in alternate runs. If I close the browser and open it again, the parameter would not be there. But if I run it again, it would be there. I know it has got to do something with response.sendRedirect, but I haven't been able to find an alternate to this.



The response.sendRedirect() sends the entire url in the redirect and that includes any query params you have. I would suggest that use a browser tool like Httpfox or LiveHeaders to inspect the headers in the response.

Are you sure you are not accessing a cached page of website A when you open a new browser?


Senthil Manoharan wrote
I think you can use JspForward instead of response.redirect.



It is not possible to 'forward' outside the context of the current application.



 
Manjusha Harimadhavan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replies!

response.sendRedirect itself works. The problem was because of something else in the JSP which was redirecting to another place based on some other condition.

reply
    Bookmark Topic Watch Topic
  • New Topic