Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How should i keep user info after successful login?  RSS feed

 
Lucas Mach
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working on a project for school where our goal is to develop a web-based book selling/buying/trading system. I'm kind of new to JSP and Java, and I'm curious as to how I should store the information of the currently logged in user.

I was reading up on jsptut.com and it seems that sessions would do the trick. At the same time, I would think that I could instatiate a class for the logged in user. Which of these is the best or most practical method?

Cheers,
--Lucas
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a class called User (or something) and after a succesful login, store the user information in the User object and then put that user object in the session.
 
Jenn Person
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should take a bit of time to check out beans. Essentially they are classes with private data members, contructors without any arguments, and have only get and set methods to set and retrieve the private data members that store your user information.
 
lee honw
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
you can use a bean check login status,if logined,the bean scorp was "session",and the bean got the data about user infomation,then return user information,if you want to log out,move the session.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!