Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Working on the mobile session same as web server

 
Ranjith Kumar Chilumuru
Greenhorn
Posts: 2
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 90
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 2
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Dhaval for your reply, I will try out the options and will respond which one is working.
 
Nauman Hasan
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

~Nauman
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic