aspose file tools*
The moose likes Other Application Frameworks and the fly likes Spring MVC + Spring security - I wonder.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Spring MVC + Spring security - I wonder...." Watch "Spring MVC + Spring security - I wonder...." New topic
Author

Spring MVC + Spring security - I wonder....

Jay Chmiel
Greenhorn

Joined: Mar 13, 2009
Posts: 8
Hi good people,

I'm coding a simple blogging portal using Spring MVC and Spring Security + Hibernate. Im stuck on problem I don't know how to solve. The problem is in create blog functionality. User inputs title of new blog and description. Now to succesfully store the new blog in DB (I want to do this from within controller) i need UserId property of Blog object to be filled in with current user in session id. But I've got no idea how to get to the id from within controller. From jsp i can use request.GetUserPrincipal().getName() and execute it agains dao, but I don't think that using dao from jsp level is a good idea. I've got this feeling that I can't see the solution which probably is simple. Help!
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

The Spring Security docs give the following code to get user details -



You could call this code in a controller or service and pass the information to your dao.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Jay Chmiel
Greenhorn

Joined: Mar 13, 2009
Posts: 8
Works fine, thanks for help .
 
 
subject: Spring MVC + Spring security - I wonder....