1

How many scopes are there in Struts 2 applications? And is it good if we use session and request scope there? How action scope work for session and request both?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Shamsuddin Altamash
  • 163
  • 1
  • 3
  • 11
  • It's not clear what you're asking. An S2 app is still a servlet-spec artifact, so the standard JEE scopes are there. S2 adds another "scope", the value stack, although it's implemented in terms of the only scopes available, the JEE-defined scopes. – Dave Newton Dec 27 '14 at 14:05
  • @DaveNewton so how request and session scopes are different from value stack(Action Scope?) – Shamsuddin Altamash Dec 27 '14 at 16:18
  • The value stack is where s2 puts its data. The value stack is contained within a JEE score (request I think). – Dave Newton Dec 27 '14 at 16:48

1 Answers1

1

Struts 2 is running a container, it has scopes for beans. More about bean scopes is in this question. All other scopes are servlet scopes. Struts uses indirect access to these scopes using it's own structures. For example a set tag uses these scopes:

The scopes available are as follows :

application - the value will be set in application scope according to servlet spec. using the name as its key
session - the value will be set in session scope according to servlet spec. using the name as key
request - the value will be set in request scope according to servlet spec. using the name as key
page - the value will be set in page scope according to servlet sepc. using the name as key
action - the value will be set in the request scope and Struts' action context using the name as key 

NOTE:

If no scope is specified, it will default to action scope.

Community
  • 1
  • 1
Roman C
  • 49,761
  • 33
  • 66
  • 176