title: Make a REST URL call to another service by filling the details from the form
body: <p>I have recently started working with Spring MVC framework. I made a lot of progress while reading lots of tutorial on the net.</p>
  
  <p><strong>Background about my application-</strong></p>
  
  <p>I have to make a REST URL call to another service (deployed already on tomcat) by using details provided in the form. So I have already made a form using JSP whose content is something like this as shown in the picture- I am not sure how can I make a REST url call by making the url from the form entries and then show the response of that url on the next screen.</p>
  
  <p>So in the above form if I have written <code>User Id as 1000012848</code> , and <code>checkbox is selected (means true) for Debug Flag</code> and in the <code>Attribute Name I have selected first row</code> ( in general we can select all three as well) and <code>Machine Name is localhost</code> and <code>Port Number is 8080</code> then url should look something like this-</p>
  
  <pre><code>http://localhost:8080/service/newservice/v1/get/PP.USERID=1000012848,debugflag=true/host.profile.ACCOUNT
  </code></pre>
  
  <p>So in all our URL that we will be making from the form entries, the below line will always be there at the same place- and then after that each form entry will start getting appended</p>
  
  <pre><code>service/newservice/v1/get/
  </code></pre>
  
  <p>Now after making the above url, as soon as I will be clicking submit, it will be making a call to the above url and whatever response it gets from the URL, it will show in the next screen (result.jsp file)  which I am not sure how to do that? Below are my files which I have created. Can anyone help me out in solving my problem? What code changes I will be needing to do this problem?</p>
  
  <p>student.jsp file (which makes the form)</p>
  
  <pre><code>&lt;%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;
  &lt;html&gt;
  &lt;res:head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
      &lt;meta name="layout" content="main" /&gt;
      &lt;title&gt;First Tutorial&lt;/title&gt;
  &lt;/res:head&gt;
  &lt;res:body&gt;
  
      &lt;form:form method="POST" action="/_hostnewapp/addStudent"&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;form:label path="userId"&gt;User Id&lt;/form:label&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;form:input path="userId" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Debug Flag :&lt;/td&gt;
                  &lt;td&gt;&lt;form:checkbox path="debugFlag" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Attribute Name&lt;/td&gt;
                  &lt;td&gt;&lt;form:select path="attributeNames" items="${attributeNamesList}"
                          multiple="true" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
  &lt;!--        &lt;tr&gt;
                  &lt;td&gt;Environment&lt;/td&gt;
                  &lt;td&gt;&lt;form:checkboxes items="${environmentList}"
                          path="environments" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
   --&gt;            
              &lt;tr&gt;
                  &lt;td&gt;&lt;form:label path="machineName"&gt;Machine Name&lt;/form:label&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;form:input path="machineName" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;form:label path="portNumber"&gt;Port Number&lt;/form:label&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;form:input path="portNumber" /&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:form&gt;
  
  &lt;/res:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>result.jsp file (which I am going to use to show the result after hitting that url)</p>
  
  <pre><code>&lt;%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;
  &lt;html&gt;
  &lt;res:head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
      &lt;meta name="layout" content="main" /&gt;
      &lt;title&gt;HostDomain&lt;/title&gt;
  &lt;/res:head&gt;
  &lt;res:body&gt;
  
      &lt;h2&gt;Response after submitting the result&lt;/h2&gt;
      // Not sure what I need to add here to show the result after hitting the url
  
  &lt;/res:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Controller Class-</p>
  
  <pre><code>@Controller
  public class SampleRaptorController {
  
      @RequestMapping(value = "/student", method = RequestMethod.GET)
      public ModelAndView student() {
          return new ModelAndView("student", "command", new Student());
      }
  
      @RequestMapping(value = "/addStudent", method = RequestMethod.POST)
      public String addStudent(@ModelAttribute("SpringWeb") Student student,
              ModelMap model) {
          model.addAttribute("userId", student.getUserId());
  
          return "result";
      }
  
  
      @ModelAttribute("attributeNamesList")
      public Map&lt;String,String&gt; populateSkillList() {
  
          //Data referencing for java skills list box
          Map&lt;String,String&gt; attributeNamesList = new LinkedHashMap&lt;String,String&gt;();
          attributeNamesList.put("ACCOUNT","host.profile.ACC");
          attributeNamesList.put("ADVERTISING","host.profile.ADV");
          attributeNamesList.put("SEGMENTATION","host.profile.SEG");  
  
          return attributeNamesList;
      }
  }
  </code></pre>