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

  • Home
  • SEARCH
  • 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 4005184
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:21:48+00:00 2026-05-20T08:21:48+00:00

I have ajax requests that come into my controller and my validation is working

  • 0

I have ajax requests that come into my controller and my validation is working great. In the controller I call a failure jsp page if there is a failure. The only problem is that I have no idea how I can output the errors to the user on the failure.jsp page. I don’t have access to the form tags of spring obviously. What should you do in this scenario?

Edit: All I really want to know is how I can access the binding errors on a JSP page when I’m using an AbstractCommandController.

  • 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-20T08:21:49+00:00Added an answer on May 20, 2026 at 8:21 am

    What I’ve done in the past is use HTTP headers to send back messages to the AJAX requester (the XMLHTTPRequest object). You will not get a full binding and validation support this way, but it’s a simple way to pass messages.

    Another option that will give you the full power of Spring binding and validation is as follows. I’m assuming you’re submitting a form via AJAX. You could do the standard spring binding and validation, and in the case of an error, send back and replace the form with the exception messages next to the problem input. This way you can leverage the full power of Spring binding and validation while getting the AJAX goodness that you want. This would require you to separate your form into a separate JSP page, so you could just return that form on AJAX submission and error.

    In response the comment

    My issue is just how to access the
    BindingErrors from a JSP if I’m using
    an AbstractCommandController. Ajax
    isn’t really that important in the
    equation. I just didn’t want to use a
    formController because it didn’t make
    sense.

    I think you can simply set a variable in your model like this:

    ModelAndView.addObject(this.getCommandName(), errors)
    

    This would be done in AbstractCommandController’s

    protected abstract ModelAndView handle(
            HttpServletRequest request,
            HttpServletResponse response,
            Object command,
            BindException errors)
        throws Exception
    

    method. Be sure the name of the model attribute is the name of your command (set in the setCommandName method).

    This is untested and from memory.

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

Sidebar

Related Questions

Is it possible that using jQuery, I cancel/abort an Ajax request that I have
I have written a web app in PHP which makes use of Ajax requests
I have an application in which most requests are submitted via AJAX, though some
I am using asp.net MVC to develop an application that will have ajax interactions.
I have some AJAX work that brings across an additional form element that I
I have an ajax toolkit TabContainer control on my page with a couple tabs.
I'm writing WatiN tests to test an Ajax web application and have come across
I've got a page on my site that requests quite a bit of content
I have a login.jsp page which contains a login form. Once logged in the
Several of my ajax applications in the past have used GET request but now

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.