Link to home
Start Free TrialLog in
Avatar of dkim18
dkim18

asked on

Getting error msg upon form submission: “The request sent by the client was syntactically incorrect”

I'm working on a Web application developed using the Spring framework, version 3.1.0.

I have a JSP page containing a form which allows the user to select a country from a SELECT dropdown listbox. Submitting the form is supposed to run a database query and return the same JSP page which includes the form as well as an HTML table of author and institute data for the selected country.

Here's part of the code for the JSP page:

<c:url var="submitUrl" value="/authorsInstitutes.htm"/>
<form:form action="${submitUrl}" method="POST">
   <select id="countryCode">
      <option value="-1">-- Please Select --</option>
         <c:forEach var="country" items="${countryList}">
            <option value="${country.countryCode}">${country.countryName}</option>
         </c:forEach>
   </select>
   <input type="submit"/>
</form:form>

Open in new window


and here's the code from the controller class, for the methods that handle the 'GET' and 'POST' requests:

@RequestMapping(value = "/authorsInstitutes", method = RequestMethod.GET)
public ModelAndView displayAuthorsInstitutesForm() {
    ModelAndView mav = new ModelAndView("authorsInstitutes");

    List<Country> countryList = countrySrv.findAll();
    mav.addObject("countryList", countryList);

    return mav;
}

@RequestMapping(value = "/authorsInstitutes", method = RequestMethod.POST)
public ModelAndView displayAuthorsInstitutes(
    @RequestParam(value = "countryCode") String country) {
    ModelAndView mav = new ModelAndView("authorsInstitutes");

    List<Country> countryList = countrySrv.findAll();
    mav.addObject("countryList", countryList);

    if (country != null && !country.trim().equals("")) {
        List<Affiliation> affiliationList = 
            affiliationSrv.getAffiliationsByCountryCode(country);
        mav.addObject("affiliationList", affiliationList);
    }

    return mav;
}

Open in new window

The 'GET' request works fine, but when I select a country and submit the form, I get a 404 error message:

HTTP Status 400 -
type Status report
message
description The request sent by the client was syntactically incorrect ().

I'm sure it's something simple, but for the life of me, I'm just not seeing what it is that I'm doing wrong. I'd appreciate any help on resolving this, thanks.
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial