Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 23rd, 2003, 07:40 AM
ramesh123 ramesh123 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: india
Posts: 5 ramesh123 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to ramesh123
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.

Reply With Quote
  #2  
Old July 23rd, 2003, 03:41 PM
Sm00ve Sm00ve is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 78 Sm00ve User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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.

Reply With Quote
  #3  
Old July 24th, 2003, 12:29 AM
ramesh123 ramesh123 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: india
Posts: 5 ramesh123 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to ramesh123
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

Reply With Quote
  #4  
Old July 26th, 2003, 05:16 PM
javakills's Avatar
javakills javakills is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Miami, FL
Posts: 47 javakills User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to javakills Send a message via Yahoo to javakills
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!

Reply With Quote
  #5  
Old July 30th, 2003, 08:33 AM
Sm00ve Sm00ve is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 78 Sm00ve User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Two Important questions (but simple)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT