Reputation: 1258
I am developing a web application with the spring framework and Hibernate as the ORM. I want to create a register and login page. On login, A session should be created for the particular user(like sending a cookie etc). Since I am new to spring, I am not aware of how to get this done. Can some one give me a good tutorial on this? Thanks!
Upvotes: 0
Views: 9976
Reputation: 1794
You can use @SessionAttributes({"form"}) to keep the form data or you can have HttpSession variable in controller signature and spring will provide you with servlets session object. Check http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html (section 15.3.2.3)
Upvotes: 0
Reputation: 121
Check this out, it describes pretty much how you should manage security with Spring
http://www.springsource.org/spring-security/
Upvotes: 1
Reputation: 691635
A HTTP session has nothing to do with Hibernate, and not much to do with Spring MVC. It's part of the standard Servlet API.
A session is started as soon as you call request.getSession()
, (request
being an HttpServletRequest
) or as soon as a JSP is executed (unless you have specifically configured it to avoid making it start a session).
You just have to assume that the session is there. It's started automatically when you get it from the request, if it doesn't exist yet.
Once a user is authenticated, you can store some user information in the session. But unauthenticated users also have a session.
Upvotes: 6
Reputation: 71
As has been pointed out this is nothing to do with Hibernate, take a look at the getting started docs for Spring Security
Upvotes: 0