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

imp.- j_security_check authenticates .. but how to set session as well ..?  RSS feed

 
sarim raza
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i have a login page, this has a form with two textfields for username, password
<form action=j_security_check>
upon submission, this mechanism works and checks if username and password exists in database and then allows the user to go on.
PROBLEM: I also need to setAttribute for a session at this point, so that in the subsequent pages I know who the user is (ie. via the username) .. in order to do that however, I would need to first 'get' the value of username field, and then 'set' the session. however my form action .. goes to this unknown j_security_check and not to a page where I have control.
so how can i incorporate some code to also set session as the value of the user as entered in the username Textfield.
thanks
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sarim
Use the HttpServletRequest method getUserPrinciple to get a java.security.Principle object then use the getName method on it.
req.getUserPrinciple().getName()
Where req is the HttpServletRequest object passed in.
hope that helps
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or request.getRemoteUser()
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!