aspose file tools*
The moose likes Servlets and the fly likes how to return an external url with cookies Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to return an external url with cookies" Watch "how to return an external url with cookies" New topic
Author

how to return an external url with cookies

enric jaen
Greenhorn

Joined: Oct 15, 2010
Posts: 25
Can you help me with this scenario?

short explanation

I have a servlet that receives a request from a user. The servlet then interacts with an external web on behalf the user. I would like the servlet to return at some point the current webpage and its cookies to the user so that she can continue using the external web from her browser.

sendRedirect isn't an option because the user loses the cookies, and because I don't want the browser makes a request, just show the same page that the servlet had.



long explanation

Timely the situation is:

t1)

user sends request to myservlet

browser url: localhost:8080/myservlet
browser window: <empty>
browser cookies: <empty>


t2)
servlet receives request.
servlet interacts with and external web web1Url
servlet returns web1 Html +web1 cookies to client

t3)

user receives response from servlet:

browser url: localhost:8080/myservlet
browser window: web1Html
browser cookies: web1Cookies


The problem in that at t3 is that the browser'url points to localhost, not to web1Url. I.e. what I would need at timestamp3 is something such as:

browser url: web1Url
browser window: web1Html
browser cookies: web1Cookies


sendRedirect isn't an option because it loses the web1 cookies.


Any idea how to do it?

If you need any clarification let me know.
 
 
subject: how to return an external url with cookies