File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Need help in Session Management Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Need help in Session Management" Watch "Need help in Session Management" New topic
Author

Need help in Session Management

Ashok Ravi
Ranch Hand

Joined: Jan 05, 2005
Posts: 48
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


SCJP | IBM XML-141 | SCWCD
Dhananjay Inamdar
Ranch Hand

Joined: Jan 27, 2003
Posts: 130
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.


Just like you, struggeling to get the right solutions!<br /> <br />Sun Certified Java Programmer 1.5<br /> <br />Target - SCWCD
Ashok Ravi
Ranch Hand

Joined: Jan 05, 2005
Posts: 48
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

Joined: Mar 30, 2005
Posts: 225
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

Joined: Nov 07, 2000
Posts: 242
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

Joined: Aug 14, 2002
Posts: 16
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.


SCJP, SCJD , SCBCD, SCMAD, SCDJWS, SCEA
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help in Session Management
 
Similar Threads
Passing data as parent->child->parent
Array troubles...
Help me out in Session Maintainance
Ajax Technology
updating ArrayList on parent from child window