title: Call JSP of another server from My Server
body: <p>I have two server and i can call jsp of another server from my server's jsp.</p>
  
  <p>like following code.
  First Server JSP.</p>
  
  <pre><code>    &lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;title&gt;JSP Page&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Hello World!&lt;/h1&gt;
          &lt;form method="post" action="http://localhost:8080/Second_App/index.jsp"&gt;
              Name : &lt;input type="text" name="name"/&gt;
              Surname : &lt;input type="text" name="surname"/&gt;
              &lt;input type="submit" value="Submit"/&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When i click on Submit the control will go in second server it will take name as parameter and put it into my Second Server's jsp.</p>
  
  <p>Second Server JSP.</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;title&gt;JSP Page&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Hello World!&lt;/h1&gt;
          &lt;% 
              String name = (String) request.getParameter("name");
              String surName = (String) request.getParameter("surname");
          %&gt;
          Name    : &lt;%= name %&gt;
          Surname : &lt;%= surName %&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>i want to do exact same thing using Servlet. </p>
  
  <p>I tried with Servlet's Redirect my control will go to Second server but because of Redirect it will not take "name" peramater.</p>
  
  <p>I tried with Forward but it is also not working because it is finding that jsp in first server.</p>
  
  <pre><code>RequestDispatcher dispatcher = request.getRequestDispatcher("http://server2/app1/index.jsp");
          dispatcher.forward(request, response);
  </code></pre>
  
  <p>My concern is JSP is Servlet. If this is done with jsp that means there should be some way for doing it with servlet.</p>
  
  <p>Thanks.</p>