File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Working on the mobile session same as web server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Working on the mobile session same as web server" Watch "Working on the mobile session same as web server" New topic

Working on the mobile session same as web server

Ranjith Kumar Chilumuru

Joined: Jul 19, 2005
Posts: 2

Dear Javaranch members,

I am just working on one requirement where i may have to provide solution for classic switch between smartphone and webserver. Please see the flow here:

User working on one application and may have to go out for some reason. In this case, he should be able to copy the session from the web server to his/her mobile and start working from there..

Is it possible through Servlets or please suggest on any other thoughts.. Thank you for your help!!
Dhaval J. Patel
Ranch Hand

Joined: Mar 10, 2011
Posts: 90

There is a way, but I am not sure if that is the cleanest way.

1) Create a map for with anything that uniquely identifies a user and the session object as value. Something like Map<User, Session>. But you will need to override hashcode() and equals() method in the User object. That key in the map is your choice, You can even have just the username and proceed. Have this map in the servlet context attributes so that all servlets can access it.

2) When a user logs in again (Not only from a mobile device but from any device) , look into this map to see if there is a session object available. I am not sure if you would be able to use the exact same session object again as the container has its own way of determining the identity of the user. You can give it a try. But if not, you can surely copy all the attributes you need to a newly created session and make it work.

I am not sure if this is the best way, but i think it should work.
Ranjith Kumar Chilumuru

Joined: Jul 19, 2005
Posts: 2

Thank you Dhaval for your reply, I will try out the options and will respond which one is working.
Nauman Hasan
Ranch Hand

Joined: Jul 27, 2005
Posts: 34
FYI: If you have multiple servers this approach may not work. Also I am not sure how the user would pass in the username from the mobile application.

That said I dont know of a good solution to this. The only thing i could suggest (and i am not 100% will work) is if the user wants to have transfer the session then create a URL for them with a post which sets the jsessionid in it using the http cookie headers and provide it to them (email may be ok - depends on how secure the application is). Then from the mobile device they can click this URL and continue their session.

I agree. Here's the link:
subject: Working on the mobile session same as web server
Similar Threads
How to test JSP from Iphone/Blackberry
Mobile website
uploading software in physical mobile
Charset Conversion
Chat Application