|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Two Important questions (but simple)
hi friends
I have two questions to ask, in jsp 1. I login in a site with the user name and password in the machine 1 and in machine two i login in again,it should not allow me to login or it should state me that ,, u have already logged in. at any point of time there should be one login . 2. i have a website in which i have many links ..all these are there in server1 and i store say around 50 variables in session. on click of the link in the server1 it takes me to server2 and i work there for some time and then i come back to server1, but my session is completely lost. how do i overcome this problem. please help me out. |
|
#2
|
|||
|
|||
|
Answer one:
You could store a yes/no value in a cookie or database that says if they are already logged in and then read it when you need to. Answer two: You could setup a persistant session config on server1 then all the variables would be present when they went back to the server. Or you could set up a shared session context between the two servers, this means that the data for both servers would live in the same session. Or you could just pop open a new window when you need to go to a different server. Then have the user's close the window when they wanted to go back to the original page. The first two options require a certain level of understanding with your appserver's config. Last edited by Sm00ve : July 23rd, 2003 at 03:43 PM. |
|
#3
|
|||
|
|||
|
thanks for the answer but
answer1: say i did not use cookied because the client can disable cookies inthe browser. if i use the database then if the user does not logout and closes the window by pressing the "X" mark on the right side top of the window. then how do i remove the user from the database ..at that time..if we dont delete then ... he will not be able to login again answer2: if i open a popup window and i work there for more than 30mts then session timeout takes place and my session data is lost. If i open in the same window then also the session is lost.. could you please tell me more about shared session context between two servers. ramesh.s |
|
#4
|
||||
|
||||
|
Ram, are you using a database to store the logins and passwords of your users? If you are, then here's what I suggest you do:
Append a boolean value on the table the will either hold true (if the user is logged in) or false (if the user is not logged in). With this you can then prompt the user for a login an password. When the form is submitted, have your servlet check the username and the true/false field first and if the value is set true, display your "Already logged in" user message. If you have no idea how database interectivity works, like me, then you can just use a plain text file to store the username and a 0 or 1 or a true and false (whatever you want) then read the file whenever someone wants to come log in. Hope this helps.
__________________
David C. Pulgar www.zenithlight.net PETER: Good morning Mr. Sun SUN: Good Morning Peter PETER: Isn't it a beautiful day Mr. Sun? SUN: It's always a beautiful day with two scoops of raisins Peter! |
|
#5
|
|||
|
|||
|
Sorry for the late post Ram I got busy with work for a few days...
For question 1: If you are afraid of the user's disableing cookies and you don't want to have a "This site requires cookies to be enabled" message then you could use the db value and in I.E.'s javascript support there is a onClose event handler so you could capture some one closing the window by either using 'alt+F4' or the x button or File->Close. You could then call a java script that calles a servlet function that changes the value in the DB. Only issue is that I am not sure if netscape supports the onClose event. For question 2: We use IBM Websphere 4.0, at my work, as our application server. There are several different configuration's that would allow you to restore/save/share a session for future usage. A. There is a setting that allows you to make a HttpSession persistant. It serializes the session as a blob and stores the session as a BLOB (Binary Large Object) which is associated with a specific user into a database. When the user re-authenticates with the server the session is re instantiated with all of the data intact. You may have to change the way you store data in the session for all of the data to be saved, I'm not sure though. B. There is also a setting in Websphere that allows 2 applications to share a single server context. This would allow a session to be shared between two differant web applications. Now, I know this works for apps on the same machine but I am not sure if you can share them between two apps on differant servers. You need to check the capabilities of your app server to determine what is supported. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Two Important questions (but simple) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|