• Post Reply Bookmark Topic Watch Topic
  • New Topic

HELP ME FILTER RECORDS!

 
Soulinger
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear CodeCharge,
I'm having a huge difficulty with the following JSP code. Please help me! It's the final part of my project that needs to be completed!
TABLES
User --> UserID, Password, GroupName (ID that matches to the next table)
Groups --> GroupID, GroupName
In my login page, there are two fields...
Login and Password.
How do I programme in JSP in such a way that when a user logs in, his UserID is stored in a session variable, and so is his GroupName (ID of Group) in another session variable?
When a user logs in, he is directed to a page where records are displayed. I wish the records that display to be only associated with his group, not the whole lot
Here is my records table
Suggestion --> SuggestionID, GroupID (matches to Group table's GroupID)
So basically, how do I use a session variable to store a value from User table when the user logs in, and how do I retrieve it in a latter page to filter records pertaining to his group only?
Please help me. Thanks a lot!
Yours,
Soulinger Wee
 
Brian Glodde
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I programme in JSP in such a way that when a user logs in, his UserID is stored in a session variable, and so is his GroupName (ID of Group) in another session variable?
Session variables are used mainly through the getAttribute and setAttribute methods. Here's a page that describes it fully:
http://www.jspinsider.com/reference/jsp/jspsession.html
When a user logs in, he is directed to a page where records are displayed. I wish the records that display to be only associated with his group, not the whole lot
That's a matter of your JDBC/SQL call. Just "SELECT userid, password FROM sometable WHERE userid = useridfromtheform AND password = passwordfromtheform". If the resultset comes back empty, then this user doesn't exist, send them to a registration page...
The solution to what you've asked is just a logic puzzle, solved by using the session variable in conjunction with your db. You've almost pseudo-coded it in your question!
Happy coding!
 
Brian Glodde
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, I believe you're going to have to change your name for this forum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!