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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:54:36+00:00 2026-05-27T16:54:36+00:00

I’m using Struts 1.2 and J2EE 1.4. I’m pretty new to Struts and Java

  • 0

I’m using Struts 1.2 and J2EE 1.4. I’m pretty new to Struts and Java so hopefully there is a simple solution for my problem. I have a page set up like this:

<div class="success">
    HTML for success
</div>
<div class="error">
    <p>We are experiencing technical difficulties at this time. Please try your request again later.</p>
</div>
<div id="contact-form-block">
    <html:form action="/reg" id="contactform">

    <br /><html:text property="firstName"/><html:errors property="firstName"/>
        <p><input type="image" src="images/reset_btn.png" id="reset" name="reset" alt="Reset" /><input type="image" src="images/submit_btn.png" id="submit" name="submit" alt="Submit" /></p>
    </div>

</html:form>
</div>

Originally the success, error and contact us divs are all hidden. I have the contact form show up on click in a modal dialog box like this:

$('.success, .error, .success_header, .error_header').hide();
$('form#contactForm').show();

So, in my Action, I want to be able to send everything back to the same input forward regardless of whether there were validation errors or not. BUT I want to have a check on the jsp page in jQuery to check to see which dialog should be displayed:

  1. The Success dialog OR
  2. The contact-us dialog with the errors

Here is my action:

if ("reg".equalsIgnoreCase(contactUsForm.getAction())) {            

        ActionMessages errors = getErrors(request);

        errors = validate(contactUsForm);

        if (errors.isEmpty()) {

           //Save some variable to the request/response to say that registration was successful

        } else {
             //save something to say that registration was not successful
            saveErrors(request, errors);
        }
    }
    return actionForward;

Is there a way to set a variable in the Action that can be retrieved in the jsp page after the ActionForward is called. Preferably accessible by jQuery in the $(document).ready function?

  • 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-27T16:54:37+00:00Added an answer on May 27, 2026 at 4:54 pm

    You would use normal Struts and/or servlet spec mechanisms.

    You could just check to see if there are errors or not; they’re stored in the request under the "org.apache.struts.action.ERROR" key; you don’t need to add anything in particular, but if you really want to, you may.

    I prefer non-form data to be stored as a request attribute:

    request.setAttribute("haveErrors", true); // Or false, obviously.
    

    You then need to get the data out of the request in your JSP, and interpreted as JavaScript:

    $(function() {
        // Use normal JSP EL; haveErrors should display as a bare string, 
        // which is valid JS. Can modify as necessary if need be.
        var haveErrors = ${haveErrors};
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.