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:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old August 16th, 2002, 11:06 AM
ph34r ph34r is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 0 ph34r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
web portal in JSP

I'm coding a web portal using JSP, Java Beans and Servlets. I've just started learning and I've run into inevitable problems.

My web portal requires users to log in, after which they can navigate around a members-only area. What I need to do is to somehow track this user so that he doesn't go into pages that he isn't authorised to see.

I'm not using Cookies since browsers can disable this feature. One way is to pass an identifier (e.g. their user name and password) from one page to the next by appending it to the URL (e.g. profile.jsp?user=ph34r&password=gkd839). This is obviously unsafe because their password will appear in the browser's Address Field.

An alternative that I have found is to use the setAttribute of the HttpSession object. However, I can only get it to work in Servlets and not JSP pages.

Any suggestions?

Reply With Quote
  #2  
Old August 16th, 2002, 04:51 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
JSP pages just use session. So, session.setAttribute( "foo", "bar" ); and session.getAttribute( "foo" ). Same thing with the request and application objects. The jsp engine builds the objects for you.

Do use sessions, though. Way less of a headache, and much more secure.

Reply With Quote
  #3  
Old August 17th, 2002, 12:31 AM
aegcp aegcp is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 1 aegcp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
also, check this

URL

JSTL, very easy to use and beautiful :-)

good luck

Reply With Quote
  #4  
Old August 19th, 2002, 11:13 AM
ph34r ph34r is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 0 ph34r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for the responses! Really appreciate it ;-)

Now I have another problem. When the user logs in, I use session.setAttribute ("userID", userID) and he is forwarded to members/home.jsp. home.jsp has a check. If userID is null, it means that the user hasn't logged in (perhaps he got to this page by typing in the URL into the Address Bar). He is forwarded back to the login page. It works for users who have never logged in before.

When the user logs out, I use session.removeAttribute ("userID") and just to make sure that his userID is no longer stored, I add a check:

<%= session.getAttribute ("userID") %>

It returns null. OK, fine.

But after logging out, when I go back to members/home.jsp by typing the URL in the Address Bar, I find that he can access the page and session.getAttribute ("userID") returns his user name. This should not be the case since he has already logged out and I have removed the userID attribute. What's going on?

Also, another thing I noticed was that when I tried to use session.invalidate () instead of session.removeAttribute ("userID") in the logout page, I get an error saying that the session is already invalidated. Why is this?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > web portal in JSP


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 3 hosted by Hostway