title: Forward from JSP to another JSP without using a servlet between them?
body: <p>I have a JSP page : </p>
  
  <p><strong>employee5_searchByName.jsp</strong> </p>
  
  <pre><code>&lt;%@page import="java.util.Iterator"%&gt;
  &lt;%@page import="java.util.List"%&gt;
  
  &lt;!-- EMPLOYEE wants to search items by their name --&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  
      &lt;title&gt;Employee - Search for items by name&lt;/title&gt;
      &lt;link rel="stylesheet"
            href="./css/styles.css"
            type="text/css"/&gt;
  
      &lt;link rel="stylesheet" type="text/css" href="css/jquery.autocomplete.css" /&gt;
      &lt;script src="http://www.google.com/jsapi"&gt;&lt;/script&gt;  
      &lt;script&gt;  
          google.load("jquery", "1");
      &lt;/script&gt;
      &lt;script src="js/jquery.autocomplete.js"&gt;&lt;/script&gt;  
      &lt;style&gt;
          input 
          {
              font-size: 120%;
          }
      &lt;/style&gt;      
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;h1&gt;Employee - Search for items by name&lt;/h1&gt;
  &lt;h1&gt;
  Search for items by name
  &lt;/h1&gt;
  
  &lt;fieldset&gt;
    &lt;legend&gt;Please enter the item's name :&lt;/legend&gt;
    &lt;form action="Employee5_After"&gt; 
      Item's name : &lt;input type="text" name="prod_name" id="myProduct"&gt;&lt;br&gt;
      &lt;script&gt;
          $("#myProduct").autocomplete("autocompleteFromDb.jsp");
      &lt;/script&gt;
      &lt;input type="submit" value="Register"&gt;
    &lt;/form&gt;
  &lt;/fieldset&gt;
  
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>It forwards to this servlet :</p>
  
  <p><strong>Employee5_After</strong></p>
  
  <pre><code>package controller.employee;
  
  /**
   * Retrieve the record of a given product by its name 
   * using hibernate
   * @author X
   *
   */
  @WebServlet("/Employee5_After")
  public class Employee5_After extends HttpServlet {
  
      private static final long serialVersionUID = 1L;
      protected void doGet(HttpServletRequest request, HttpServletResponse response) 
              throws ServletException, IOException 
      {
          // grab the product's name that the user entered
          String productName = request.getParameter("prod_name");
  
          // create DB instance
          DatabaseInventory inventory = new DatabaseInventory();      
  
          // get the details
          String details = inventory.getProductDetailsByName(productName);
          HttpSession session = request.getSession();
  
          // forward answer to JSP 
          synchronized(session) 
          {
              if (details != null) // then the product has been found
              {
                  session.setAttribute("foundProd", details);
                  String addressPath = "/WEB-INF/results/employee/employeeResult5.jsp";
                  RequestDispatcher dispatcher = request.getRequestDispatcher(addressPath);
                  dispatcher.forward(request, response);
              }
          }
      }
  
  }
  </code></pre>
  
  <p>That servlet is doing his stuff , and then forwards to a 2nd JSP ,called : </p>
  
  <p><strong>employeeResult5.jsp</strong></p>
  
  <pre><code>&lt;!-- Employee - get a description of a product by its name --&gt;
  
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;&lt;title&gt;The details for the product you requested are below&lt;/title&gt;
  &lt;link rel="stylesheet"
        href="./css/styles.css"
        type="text/css"/&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Here are the details from the product you request :&lt;/h1&gt;
  &lt;h2&gt;${foundProd}&lt;/h2&gt;
  &lt;h1&gt;We wish you well - bye bye!&lt;/h1&gt;
  
  
  &lt;fieldset&gt;
    &lt;legend&gt;Go back to Employee's web-page&lt;/legend&gt;
     &lt;form action="blablabla"&gt; 
      &lt;a href="backToEmployeeMenu"&gt;Press here to continue&lt;/a&gt;
    &lt;/form&gt;  
  &lt;/fieldset&gt;
  
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>I guess that I can use the <code>&lt;%</code> and <code>%&gt;</code> in the JSP to do the logic side of the servlet (contacting to DB and retrieve data) . How can I avoid using a servlet in between , and just pass the data from one JSP to another JSP ? </p>