my dog learned polymorphism
The moose likes Struts and the fly likes scope of the request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "scope of the request" Watch "scope of the request" New topic

scope of the request

sunny mak

Joined: Jun 11, 2006
Posts: 12
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.

There is always Something!
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.

Consultant, Sima Solutions
sunny mak

Joined: Jun 11, 2006
Posts: 12
Thanks Higginson . I am clear now.
I agree. Here's the link:
subject: scope of the request
It's not a secret anymore!