Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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

 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
or request.getRemoteUser()
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic