Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help in Session Management

 
Ashok Ravi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
The following is the scenario in which i need help in maintaining the session.
1. My webpage contains lot of form elements like text boxes, check boxes, text areas etc. The user enters data into it and uses these elements accordingly.
2. Now if the user uses ctrl+N to open a new browser window, the same webpage appears but without the data that is entered in the form elements.
3. The session is maintained internally but i need a way to get the data from the form elements and put it into the new window being opened.
I'm using Websphere Studio Site Developer as my IDE. Is there any option available with it to handle this situation? Or is there a way to block generating a new window?

All of ur suggestions will be highly valuable...

Thanks,
Ashok R
 
Dhananjay Inamdar
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

You can trap the Ctrl+N combination and avoid user from opening a new window using javascript. The code will be as follows


This is tested and prooved code.
 
Ashok Ravi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dhananjay,

Instead of blocking the ctrl+N option, is there a way to handle this situation? Will server side cookies help in this scenario? Since this project deals with the medical informations, handling the new browser window is highly recommendable. Please help me on this..

Thanks,
Ashok R
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ashok,

even if you open a new window, i think the session is maintained. and you are right about cookies. if session is maintained, you can use the session info to populate the form items.

can you try doing the following?



and see the output 1. after opening the first window, 2. after doing ctrl + N.

my guess is that you will not get the session null the next time.

make sure u dont do


since this will make a new session object if the session is null and return that to you.
 
Santhosh Kumar
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ashok,

Let me understand your problem clearly.

1. User loads one ofyour pages (ex., abc.jsp)
2. User type some data into the forms of abc.jsp
3. User presses Ctrl+N to open a new browser window.

Now in the new window, the user entered data is not visible.

If I have understood the steps clearly, it is very evident that, data will not be displayed. Because in step 3, when users press Ctrl+N, browser will request the server again for abc.jsp. At this time, server will not know the data entered by user in step 2, as this data has not been sent to the server.

The best way to handle, if you can, is train the users and inform the implications of doing these steps.

If they still insist on achieving this, you can do one thing though. Try to capture the Ctrl+N and submit the form. So that when users open the new browser, when browser requests again for abc.jsp file, you can paint the data back.

PS: This isjust my idea, and I have not implemented anything like this before. In personal opinion, doing these "by hook or crook" things, you will have some or the other problems or issues, which you will not have control about. So suggested you convience your users to enter data only after opening the new window or saving the page, before pressing Ctrl+N.

Hope this helps.
 
Paul Wong
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, you can try checking out AJAX. One good site is AJAX in Action. With AJAX, what you might be able to do is for every onblur of a FORM, have AJAX send it to the backend to save into the session. So when the user calls a new window with Ctrl+N, it should have values in the session already.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic