Forums Register Login

store applet session using servlet

+Pie Number of slices to send: Send
I'm sutharshan and i'm developing a small game applet.

I have a problem that when a user logs in to the website, i need to restore the old game apple state to the user and when he logs out i need to store it using servlet or any other way.

Every user id have different applet state and i need to restore them according to the user id.

I dont know how to use the HttpSession in this issue.

Please help me in this issue, with sample codes. i dont have any idea how to implement this.

please help me.
+Pie Number of slices to send: Send
"Sutha",
Please see your private messages about an important administrative matter.
+Pie Number of slices to send: Send
HTTP sessions are not a good way to store state between logins. Sessions are generally used to store state during logins, but not for prolonged periods. That's why they're generally set to expire after an hour or so if they're not accessed.

Maybe the servlet can store the state in a more permanent place, like a file or database?
+Pie Number of slices to send: Send
Friends,

I'm not having a idea how i'm going to do this project. But i have to store the current state of the game applet associated to every user id. It doesnt matter to use servlet or anything. I dont wont to use cookies. I need a solution with example source code. Please help me in this
+Pie Number of slices to send: Send
We'll try to help you, but not by handing out code. You'll learn much more by figuring this out on your own.

So: You were talking about servlets - does that mean you have you have a servlet container running on the same machine from where the applet is hosted? If so, the applet can use the HttpUrlConnection class to send data to a servlet; see http://www.exampledepot.com/egs/java.net/pkg.html for examples, particularly e135.

Of course, to save the data, a user ID of some kind needs to be stored along with it, so that if a user returns he can be recognized. Do you have a login mechanism of some kind in the applet?

Finally, to read existing data if the applet is started again later, you could do the reverse of what you did to store the data, or you could embed the data in parameter tags inside the applet tag. That would mean that the user logs in not in the applet, but into the web app, so that the web app can dynamically create the applet page based on that user's data.

Does this help?
+Pie Number of slices to send: Send
i have a jsp form to login and when the user logs in the game applet should load where he left out last time.

i have design the game applet, but i dont know how to use the object persistence with the users and the applet. i dont know how to implement the persistence in applet and also how to store that object in server?

please help me in this with some small sample codes, for using persistence in applet and for the object store


thanks in advance
+Pie Number of slices to send: Send
A small code sample is not going to do it. There are quite a few parts to this: 1) the applet must transfer the persistent data to a servlet, 2) the servlet must store that data somewhere (in a file or database), 3) upon login into the web app, a servlet needs to read the persistent data and write it via parameter tags into the applet tag, 4) the applet needs to read the values from the parameter tags. Only the 4th step is quite simple.

Alternatively, you could try the AppletContext's getStream and setStream methods. They're supposed to let you store data locally, but I haven't had much luck getting those to work.
[ November 18, 2008: Message edited by: Ulf Dittmer ]
+Pie Number of slices to send: Send
How to pass the object persistence through the applet parameters and how the applet will understand that?

IF we do like that, is it safer?

Thanks for your response
+Pie Number of slices to send: Send
The link I posted explains about parameter tags. A more detailed explanation can be found at http://java.sun.com/docs/books/tutorial/deployment/applet/html.html

I'm not sure what you mean by safer? Safer than what?
Won't you be my neighbor? - Fred Rogers. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2289 times.
Similar Threads
Saving and Restoring Form Data
Full Screen on Maximize
assigning dynamic values to table column
Persistent session and HttpSession...
GAE Auto Restarting Every 30 to 60 seconds.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 03:53:06.