Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

scope of the request

 
sunny mak
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i am new to struts .can any one explain why should the scope of the request in struts should be only in request or session . why not in others like application.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since application scope applies to all users of the web application, it wouldn't make any sense at all to put an ActionForm in Application scope, since an ActionForm represents one user's interaction with the application. The only scopes that make sense are request, which spans only a single request to the server, or session, which spans multiple requests from the same user.

If there are portions of the ActionForm that do apply to all users, it's a good idea to separate those out and put them in Application scope rather than in the form bean. For example, suppose you have a select box that allows the users to select one of the 50 US States. Since that list of States doesn't change from one user to the next, you could put only this list in Application scope and leave the rest of the ActionForm in request or session scope.
 
sunny mak
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Higginson . I am clear now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic