• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off

Card Range To Study



Play button


Play button




Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

11 Cards in this Set

  • Front
  • Back
Walk me through the 10 step struts 2 request flow.

1. Request - Container - Filters incl ActionContextCleanup (optional ) and/else FilterDispatcher
2. FilterDispatcher consults ActionMapper
3. FilterDispatcher calls ActionProxy
4. ActionInvocation created by ActionProxy
5. Interceptors before
6. Action execute
7. Result and JSP
8. Interceptors after
9. Response returned through Filters
10. FilterDispatcher cleanup or ActionContextCleanup

1. Request goes to the Servlet container and is passed through a standard filter chain with the addition of ActionContextCleanup (optional) and FilterDispatcher.
2. FilterDispatcher consults ActionMapper to see if an Action is to be invoked.
3. If yes, FilterDispatcher delegates control to ActionProxy.
4. ActionProxy consults configuration and creates an ActionInvocation and initiates the Interceptor stack.
5. The before clause of each Interceptor is called until the execute method is called at the bottom of stack.
6. When the Action's execute method completes, the ActionInvocation references and executes the proper result according to configuration.
7. If appropriate, a template technology such as JSP is rendered including tags and urls for additional requests.
8. After clause of each interceptor is called (Reverse order since the calls are nested)
9. Response is returned through the Servlet filters.
10. Filter Dispatcher will not clean up ThreadLocal if ActionContextCleanup is present but does otherwise.
How does one create an Action in Struts 2?
Struts 2 uses reflection to find an appropriate method which by default is the execute method. Best practice however should be to implement the Action interface or extend ActionSupport.
What kind of MVC is Struts 2?
Struts 2 is a front controller MVC which is to say that the user interacts with the controller before the UI. You send a request and a controller or Action responds with the mapped UI components. When examined from the push/pull perspective, Struts2 is a Pull-MVC based architecture, in which all data is stored in Value Stack and retrieved by view layer for rendering.
In struts.xml, what does the attribute "method" stands for in the "action" tag?
The method attribute tells the name of the method invoked after setting the properties of the action. This attribute can hold the name of the method or the index of the result mapping.

For example:

<action class="com.company.app.Login" method="login" name="login">
<result name="success">/success.jsp</result>
<action class="com.company.app.Login" method="{1}" name="login">
<result name="login">/success.jsp</result>

In both, the method signature is
public String login()
Are Interceptors thread safe?
No, and they are supposed to be stateless according to the documentation.
Are Actions thread safe?
Struts 2 actions are but old Struts 1 actions were not. New struts actions are created per each request in Struts 2.
How are Interceptors and Servlet Filters different?
1. Filters are part of the Servlet API, Interceptors are Struts 2.
2. The Interceptor stack fires on requests in a configured package while filters only apply to their mapped URLs.
3. Interceptors can be configured to execute or not depending on specific target action methods via excludeMethods and includeMethods while Filters lack this feature.
4. Filters are an implementation of the Intercepting Filter pattern while Interceptors are of the Interceptor pattern.
What is struts.devMode and why it is used?
struts.devMode is a key used in struts.properties file or a constant configured instruts.xml file. It determines if the framework is running in development or production mode & is boolean. Dev mode gives the following benefits :
1. Resource bundle reload on every request; i.e. all localization properties file can be modified and the change will be reflected without restarting the server.
2. struts.xml or any configuration files can be modified without restarting or redeploying the application.
3. When errors occur in the application they will be displayed as stack traces, as oppose to production mode.

struts.devMode should be marked as false in production environment to reduce impact of performance. By default it is "false"
How can duplicate form submission be handled in Struts 2?
The problem of duplicate form submission arises when a user clicks the Submit button more than once before the response is sent back. This may result in inconsistent transactions and must be avoided. In Struts this problem can be handled by using the saveToken() and isTokenValid() methods of Action class. saveToken() method creates a token (a unique string) and saves that in the user’s current session, while isTokenValid() checks if the token stored in the user’s current session is the same as that was passed as the request parameter.
Whats the difference between the default namespace and the root namespace?
The default namespace is "" - an empty string. The default namespace is used as a "catch-all" namespace. If an action configuration is not found in a specified namespace, the default namespace is also searched. Root Namespace: A root namespace ("/") is also supported. The root is the namespace when a request directly under the context path is received. As with other namespaces, it will fall back to the default ("") namespace if a local action is not found.
What are Pull and Push MVC architecture and which architecture does Struts2 follow?
In Push-MVC the model data is given to the view layer by putting it in scoped variables like request or session. Typical example is Spring MVC and Struts1.

Pull-MVC supposedly puts the model data in a common place i.e. in actions, which then gets rendered by view layer. Struts2 is supposedly a Pull-MVC based architecture, in which all data is stored in the Value Stack and retrieved by the view layer for rendering. I don't agree with this viewpoint since by definition of "view", it must be composed of pure HTML and/or JavaScript. Thus niether tags nor the Value Stack counts as "view layer" as both of these are Java or handled by Java before.