INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Spring framework-Getting error msg upon form submission

Spring framework-Getting error msg upon form submission

Spring framework-Getting error msg upon form submission

(OP)
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:

CODE --> JSP

<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> 

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

CODE --> Java

@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;
} 

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close