Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 703971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:53:23+00:00 2026-05-14T03:53:23+00:00

On default I want my struts2 app to forward to an action: <?xml version=1.0

  • 0

On default I want my struts2 app to forward to an action:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="false" />

    <package name="myApp" namespace="/myApp" extends="struts-default">


        <action name="Login_*" method="{1}" class="myApp.SessionManager">
            <result name="input">/myApp/Login.jsp</result>
            <result type="redirectAction">Menu</result>     
        </action>

    </package>

    <package name="default" namespace="/" extends="struts-default">
        <default-action-ref name="index" />
        <action name="index">
            <result type="redirectAction">
                <param name="actionName">Login_input.action</param>
                <param name="namespace">/myApp</param>
            </result>
        </action>
    </package>


</struts>

I’m looking for the application to call SessionManager.input(), but instead it calls SessionManager.execute().

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:53:23+00:00Added an answer on May 14, 2026 at 3:53 am

    You don’t want typically a public input() method. The most basic and typical scenario for an Action is:

    • The Action is intended to “do something” (one thing), and this action needs some user input.
    • The Action does than something in the method execute()
    • If the Action did succesfully that something, it returs SUCCESS. This triggers a result informative JSP page.
    • If the Action didn’t get the user input (because there wasn’t any, or because it was insufficient or wrong) it returns INPUT. This triggers a “input form” JSP so that the user can fill the data and (re)try the action.

    Now, this basic scenario can be coded in several ways, among them:

    1) Two different mappings, one for the input form, other for the execution

    <!-- default action class: execute does nothing, returns SUCCES -->
    <action name="ActionXXXShowForm"> 
                    <result>/myApp/XXXForm.jsp</result>
    </action>
    
    <action name="ActionXXX" class="myApp.XXXAction"> 
                    <result name="input">/myApp/XXXForm.jsp</result>
                    <result>/myApp/XXXDone.jsp</result>
    </action>
    

    2) Just one mapping

    <action name="ActionXXX"  class="myApp.XXXAction"> 
                    <result name="input">/myApp/XXXForm.jsp</result>
                    <result>/myApp/XXXDone.jsp</result>
    </action>
    

    Both are very similar (specially if your are doing programmatic validation).
    In both cases, we have only a “struts” method in the action (execute), which is good practice as our action only “does one thing”.
    But in the second case, we need to deal with the case in which no data is post, and dont emit an error message for that case.

    Example: In case 1:

    public class XXXAction extends ActionSupport {
        ...    
        public String execute() throws Exception {
            if(! inputOk()) return INPUT;
             // .. do your stuff
            return SUCCESS;
        }
    
        private boolean inputOk() {
           // ... check your inputs - sort of programatic validation
           if( surname == null ) addActionError("no surname");
           // .... more checks
           return ! hasActionErrors());
        }
    
    }
    

    In case 2 you modify it slightly:

    public class XXXAction extends ActionSupport {
        ....    
        public String execute() throws Exception {
            if( emptyInput() ) return INPUT;  // no error messages in this case
            if(! inputOk()) return INPUT;
             // .. do your stuff
            return SUCCESS;
        }
    
        private boolean inputOk() {
           // same as before
        }
    
        private boolean emptyInput() {
           // detect no input was sent. do not emit errors herer
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to generate xml file from Struts action object. So that I have
I want to use the default XML editor (org.eclipse.wst.xml.ui) of Eclipse in an RCP
I want to componentization my project by using struts2 tiles plug-in. The tiles.xml file
How can I set a default VirtualHost in Apache? Preferably, I want the default
i ahave an app with struts2.2 and spring 3.1 and i want to disable
By default, Struts 2 uses the suffix .action to represent action URLs. So, even
Basically whenever someones opens up my (Google) map I want it default to their
I want to get Default Windows Forms Unhandled-Exception Dialog whenever my C# application encounters
I want to give default value to a textarea. The code is something like
I want to lookup the default value of a column in my SQL2005 database.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.