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 8727607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:27:57+00:00 2026-06-13T08:27:57+00:00

I have a form that I need to be validated when submitted. I have

  • 0

I have a form that I need to be validated when submitted. I have added public void validate() to my action class. However, the errors are displayed even in the initial page load when the form was not yet submitted.

I have read this and this, but nothing solved my problem. Is it really that hard to implement such simple things as skipping validation on first form load? 🙁

I am using manual validation inside action class.

struts.xml

<action name="login" class="community.action.LoginAction">
    <result name="success" type="redirect">/forums/list</result>
    <result name="login">/WEB-INF/login.jsp</result>
    <result name="input">/WEB-INF/login.jsp</result>
</action>

LoginAction.java

public void validate() {
    //validation rule
    addActionError("Error message");
}

public String execute() {
    if (//username and password correct) {
        return SUCCESS; //redirect to forums page
    } else {
        return LOGIN;
    }
}

Currently the errors display even if form is not submitted.

I tried to use the @SkipValidation annotation over execute(), but this prevents errors from being shown at all, even after form submission.

  • 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-06-13T08:27:58+00:00Added an answer on June 13, 2026 at 8:27 am

    You can have one more method in the LoginAction class to return the login.jsp for the Input with @SkipValidation

    LoginAction.java

         public String execute()
            {       
                 if (//username and password correct) {
                   return SUCCESS; //redirect to forums page
                 } else {
                 return LOGIN;
                  }     
            }
    
        public void validate()
         {
                 //validation rule
                  addActionError("Error message");
         }
    
    
        @SkipValidation
        public String loginForm()
         {
                return INPUT;
         }
    

    Now the validation will occur only on execute method. First the request should come to loginForm method.To make this,slight modification in the configuration

    struts.xml

    <action name="login_*" class="community.action.LoginAction"  method="{1}">
        <result name="success" type="redirect">/forums/list</result>
        <result name="login">/WEB-INF/login.jsp</result>
        <result name="input">/WEB-INF/login.jsp</result> </action>
    

    Here method=”{1}” entry in the action element will be used to check which method got requested for, if nothing is specified in the request then the execute() method will be invoked otherwise mentioned method will be invoked.Note the action name has changed to login_*

    To mention the method name in the JSP:


      -------
      <s:submit name="SubmitButton" value="Click To Login" action="login_loginForm"/>
    


    In the submit UI element above action have got mentioned as login_loginForm. Here login_ refers the action name and loginForm refers the method to be invoked. Hope this will help

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following (simplified) conditions that need to be validated for a form
I have a hidden button on a form that I need to click in
I have a form that has a group of 3 text_fields. I need two
I need to make the program which have one form that contains PNG image
i have a windows form that contains a bunch of textboxes. I need a
I have an html/php form that updates entries on the database server. I need
I have a timed page that I need to use to submit a form
I have a webpage that contains a form, and i need to refresh the
I have this java servlet that grabs information from a form, I need to
I've a form that is being validated with Jquery's Validation Plugin and I need

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.