wood burning stoves 2.0
The moose likes Servlets and the fly likes Pass session information to browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Pass session information to browser" Watch "Pass session information to browser" New topic

Pass session information to browser

Sparsh Shetty

Joined: May 13, 2003
Posts: 2
I have a java application that connects to a servlet. Once the connection is made, I want to pass the same session to a browser (opened through Runtime.exec).
Is this possible? If not, what are the alternatives.
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
You are trying to maintain the SAME session across the server and the client? You can pass a serialized COPY of the session object to the client, but it is a different object. The server session lives in a different JVM than the browser uses.
Are you just trying to make sure that you close the server session when the client closes, or what?

"JavaRanch, where the deer and the Certified play" - David O'Meara
Philip Shanks
Ranch Hand

Joined: Oct 15, 2002
Posts: 189
This sounds like one server and two clients, both using the same session. I just have to ask why?
I'm not trying to give you a hard time. It's just that this seems to be outside of the normal sessions paradigm, so it makes me ask, what are you trying to accomplish with this scheme? It may be that there is a better way to do it that doesn't involve session sharing and the accompanying potential for concurrency issues.
If I had to guess, it sounds like you want to establish the session with the java client, and then pass the session to a web browser. If this is the case, then you have to keep in mind that the notion of a session lives entirely on the server.
While it may be possible to fool the server into thinking that there is only the one client, it may be difficult. The active session ID would have to be encoded into the browser's first request. Or, you would somehow have to construct a valid session cookie in the browser. Either way, I don't know if it would work.
I think I would need a little better idea of what you want to do before I give "my final answer."
[ May 14, 2003: Message edited by: Philip Shanks ]

Philip Shanks, SCJP - Castro Valley, CA
My boss never outsources or has lay-offs, and He's always hiring. I work for Jesus! Prepare your resume!
Sparsh Shetty

Joined: May 13, 2003
Posts: 2
Thank you for the response.
The scenario is, my Oracle forms application executes the java application through the OS class by passing in the username and password.
Philip, you are right. Its this java application that connects to the servlet, establishes a session and has to then open a browser and pass the same session to it. And the issue is to pass the same session to the browser.
Looking forward to your help.
I agree. Here's the link: http://aspose.com/file-tools
subject: Pass session information to browser
It's not a secret anymore!