File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session in struts

 
sihani rani
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In struts , session creation code is1)what is the use of session.put("logined","true")?

2)Map sessionlog=ActionContext.getContext.getSession(); is create new session or get already created session (old session)?

please reply me. thanks in advance.
 
Ankit Garg
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts strives for a clean MVC design, so to decouple your action from the servlet environment, struts allows you to access session (and request, context) attributes through a Map. This way you can test your actions more easily and the actions don't have knowledge that its running in a web application. So when you call ActionContext.getContext.getSession(), you get a Map of Session attributes. If there is no existing session, it will be created, otherwise you'll get a Map of existing session attributes. When you call put on the Map object, you are basically adding a session attribute...
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code is cleaner and easier to test if you implement SessionAware, though. It eliminates the need for an ActionContext in the test environment--all you need is a map.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic