title: I am getting an error when I am trying to manipulate form data in a spring mvc controller
body: <p>Ok, I am doing something wrong here but I don't know what.
  So here is the code :</p>
  
  <p>hello.jspx :</p>
  
  <pre><code>&lt;jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns="http://www.w3.org/1999/xhtml" version="2.0"&gt;
      &lt;jsp:directive.page contentType="text/html;charset=UTF-8"/&gt;
      &lt;jsp:output omit-xml-declaration="yes"/&gt;
      &lt;html&gt;
      &lt;head&gt;&lt;title&gt;Simple jspx page&lt;/title&gt;&lt;/head&gt;
      &lt;body&gt;
      Place content here ${message}
  
      &lt;form method="get" action="sendParameters"&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;City:&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="cityName" id="cityId"/&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;State:&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="stateName" id="stateId"/&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Arrival Date:(MM/DD/YYYY)&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="arrivalDateName" id="arrivalDateId"/&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Departure Date:(MM/DD/YYYY)&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="departureDateName" id="departureDateId"/&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td colspan="2"&gt;
                  &lt;input type="submit" value="Submit"/&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
      &lt;/form&gt;
  
      &lt;/body&gt;
      &lt;/html&gt;
  &lt;/jsp:root&gt;
  </code></pre>
  
  <p>results.jspx :</p>
  
  <pre><code>&lt;jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns="http://www.w3.org/1999/xhtml" version="2.0"&gt;
      &lt;jsp:directive.page contentType="text/html;charset=UTF-8"/&gt;
      &lt;jsp:output omit-xml-declaration="yes"/&gt;
      &lt;html&gt;
      &lt;head&gt;&lt;title&gt;Simple jspx page&lt;/title&gt;&lt;/head&gt;
      &lt;body&gt;Place content here : ${message}&lt;/body&gt;
      &lt;/html&gt;
  &lt;/jsp:root&gt;
  </code></pre>
  
  <p>HomeController.java :</p>
  
  <pre><code>package com.apress.prospring3.ch17.web.controller;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.ModelMap;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RequestParam;
  
  import java.io.BufferedReader;
  import java.io.InputStreamReader;
  import java.net.URL;
  import java.net.URLConnection;
  
  @Controller
  @RequestMapping("/")
  public class HomeController {
      @RequestMapping(method = RequestMethod.GET)
      public String printWelcome(ModelMap model)
      {
          model.addAttribute("message", "Hello user!");
          return "hello";
      }
  
      @RequestMapping(value="/sendParameters", method = RequestMethod.GET)
      public String createUrl(ModelMap model, @RequestParam("cityName")String cityName, @RequestParam("stateName")String stateName, @RequestParam("arrivalDateName")String arrivalDateName, @RequestParam("departureDateName")String departureDateName) throws Exception
      {
          String myUrl = "http://api.ean.com/ean‑services/rs/hotel/v3/list?minorRev=20" +
                  "&amp;cid=55505" +
                  "&amp;apiKey=123456789" +
                  "&amp;customerUserAgent=Mozilla/5.0 (Windows NT 6.2; Win64; x64;) Gecko/20100101 Firefox/20.0" +
                  "&amp;customerIpAddress=192.168.1.1" +
                  "&amp;locale=en_US" +
                  "&amp;currencyCode=USD" +
                  "&amp;city=" + cityName +
                  "&amp;stateProvinceCode=" + stateName +
                  "&amp;countryCode=US" +
                  "&amp;supplierCacheTolerance=MED" +
                  "&amp;arrivalDate=" + arrivalDateName +
                  "&amp;departureDate=" + departureDateName +
                  "&amp;room1=2" +
                  "&amp;numberOfResults=1" +
                  "&amp;supplierCacheTolerance=MED_ENHANCED";
  
          URL yahoo = new URL(myUrl);
          URLConnection yc = yahoo.openConnection();
          BufferedReader in = new BufferedReader(
                  new InputStreamReader(
                          yc.getInputStream()));
          String inputLine;
  
          while ((inputLine = in.readLine()) != null)
              System.out.println(inputLine);
          in.close();
  
          model.addAttribute("message", "Results ready!");
          return "results";
      }
  }
  </code></pre>
  
  <p>The error appears just after I press submit, and it is the following :</p>
  
  <blockquote>
    <p>HTTP Status 500 - Server returned HTTP response code: 400 for URL:
    <a href="http://api.ean.com/ean" rel="nofollow">http://api.ean.com/ean</a>‑services/rs/hotel/v3/list?minorRev=20&amp;cid=55505&amp;apiKey=123456789&amp;customerUserAgent=Mozilla/5.0
    (Windows NT 6.2; Win64; x64;) Gecko/20100101
    Firefox/20.0&amp;customerIpAddress=192.168.1.1&amp;locale=en_US&amp;currencyCode=USD&amp;city=Seattle&amp;stateProvinceCode=WA&amp;countryCode=US&amp;supplierCacheTolerance=MED&amp;arrivalDate=09/04/2013&amp;departureDate=09/05/2013&amp;room1=2&amp;numberOfResults=1&amp;supplierCacheTolerance=MED_ENHANCED</p>
  </blockquote>
  
  <p>Any ideas?
  Thank you.</p>