title: calling a jsp from a servlet
body: <p>I'm calling a JSP, <code>displayItems.jsp</code> from a servlet, <code>DataPortal.java</code>. First I tried to do this using the <code>RequestDispatcher</code> like this,</p>
  
  <pre><code>String url = "/displayItems.jsp";
  ServletContext context = getServletContext();
  RequestDispatcher dispatcher = context.getRequestDispatcher(toDo);
  dispatcher.forward(req, res);
  </code></pre>
  
  <p>well... the control did go to the JSP page, however it printed the entire contents of the JSP file (including tags and everything) instead of displaying as a webpage. Next I tried to achieve this by using <code>response.sendRedirect(url);</code> and this time it gives me an empty page. What am I doing wrong here? The JSP is like this,</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="content-type" content="text/html;charset=utf-8"/&gt;
      &lt;meta http-equiv="Pragma" content="no-cache" /&gt;
  &lt;meta http-equiv="expires" content="0" /&gt;        
  &lt;meta http-equiv="Content-Style-Type" content="text/css" /&gt;
  &lt;script src="http://jqueryjs.googlecode.com/files/jquery-1.3.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;/head&gt;
      &lt;body&gt;
      &lt;div&gt;i am in display category&lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Any help is appreciated.</p>