Forums Register Login

Session Object

+Pie Number of slices to send: Send
Hi to all,
I have a question related to JSP and Servlet.In my application on the logon page we create a session and a successfull database connection and use that session object and database connection for a entire session. Now problem start here, at one of my web page i have a applet and that applet is doing servlet communication.
My question is that can i use same session object for the applet servlet communication? can i use same database connection for this communication? please help me guys.
Quick help would be appreciated because i have to write document for it.
waiting for your help.
regards
vivek
[This message has been edited by Vivek Shrivastava (edited July 12, 2000).]
+Pie Number of slices to send: Send
Any Help Please.
+Pie Number of slices to send: Send
Vivek,
The applet will invoke your servlet with a </b>different session id</b> altogether.This means that when you start the session, you should keep that <b>session id </b> and pass it <b>back and forth during your servlet-applet communication </b>.In that way you can use the same object by always comparing the <b>original session id </b>.
I hope this makes sense. If I am not clear, let me know, I can try again.
Good luck,
Herbert.
+Pie Number of slices to send: Send
Hi Herbert,
I really appreciate your effort. my problem is that i want to use one session id for entire session which i cretaed at the time of login(from a login JSP page) and also want ot use same database connection object cretaed(from a login JSP page) same time.
I create connection to servlet using following command :
URL VCIservlet = new URL( webServerStr );
URLConnection VCIConnection = VCIConnection.openConnection();
so i think now u can think of something better. is there any way i can use same session and connection object. because we are not supposed to have more then one database connection per user logged on site.

Please help me.
vivek
[This message has been edited by Vivek Shrivastava (edited July 13, 2000).]
+Pie Number of slices to send: Send
Any help please!

vivek
+Pie Number of slices to send: Send
You should be able to pass the cookie information to the applet and thus get at the sessionid. Just write a <param line when writing the <applet tag (assuming your base page is written by a servlet.)
However, it is real easy to create the equivilent of a session under your own control and escape the restrictions of HttpSession.
Saving the database connection is probably not such a good idea, why not use a connection pool?
+Pie Number of slices to send: Send
Hie Vivek,
I am assuming that the task of session management is being done at the servlet.That is I am assuming that somewhere in your servlet you have something like
<p align =left>
<br>
<b>HttpSession session = request.getSession(true)</b>
</br>
</p>
Given that, then I am also assuming that after getting the session( creating if it did not exist), you are doing some operation to obtain the session object that corresponds to this session. Something like
<p align =left>
<br>
<b>yourSessionObject = session.getValue(yourSessionKey)</b>
</br>
</p>
Now after invoking this method, if the current session has a session object bound to it,retrieved by whatever key, then you should expect <b>yourSessionObject</b> to have value.
But as I was saying, when you invoke <b>request.getSession()</b> as a result of a call from the applet,the session id returned will be different from the <b>original session id</b> because applets and servlets store their cookies in different places.Consequently,you will not succeed in obtaining your session object that corresponds to the current session, as known by the servlet.
So I was suggesting that, at the point where you are creating the session and binding the sessionID with its corresponding session object, you should attempt to store this session id and pass it along, as the communication proceeds <b>servlet-applet-servlet</b> so that instead of using <b>getSession</b>,you should use your this original session ID to obtain the session object.
Hope this helps,
Herbert.
There's a way to do it better - find it. -Edison. A better tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1047 times.
Similar Threads
Applet JDNI database connection
Comparing Session Management between JavaBean and Servlet.
Reagarding Applet accessing database
question for author Aaron Mudler
passing custom object from jsp to applet
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:30:27.