title: Pass data from servlet to jsp without forms?
body: <p>So what I'm basically trying to do here is get a list of hotels in JSP , from the servlet , without any forms.</p>
  
  <p>This is my JSP:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  
  "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;ul&gt;
      &lt;c:forEach var="elem" items="${list}"&gt;
      &lt;li&gt;${elem.name}&lt;/li&gt;
      &lt;/c:forEach&gt;    
  &lt;/ul&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Servlet function:</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws                           ServletException, IOException {
  
  
      try {
          java.util.List&lt;Hotel&gt; list = model.getAllHotels();
          request.setAttribute("list", list);
          RequestDispatcher rDispatcher = request.getRequestDispatcher("/index.jsp");
          rDispatcher.forward(request, response);
  
      } catch (SQLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>Now I know how to do this via form with get / post , since the servlet has specific functions for that. But how can I send this data without forms ?</p>