title: how to translate servlet to JSP?
body: <p>Can you help me translate a <strong>Servlet</strong> to <strong>JSP</strong></p>
  
  <p>here's the code:</p>
  
  <pre><code>package Inventory;
  
  import java.io.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  public class DisplayData extends HttpServlet {
  
  public void doGet(HttpServletRequest request,
          HttpServletResponse response)
          throws ServletException, IOException {
  
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
      Item item = (Item) request.getAttribute("invenItem");
  
      if (item != null) {
          out.println("&lt;html&gt;&lt;title&gt;Inventory Item&lt;/title&gt;");
          out.println("&lt;body&gt;&lt;h1&gt;Inventory Item Details:&lt;/h1&gt;");
          out.println("Stock ID  : " + item.getStockID() + "&lt;br/&gt;");
          out.println("Name      : " + item.getItemName() + "&lt;br/&gt;");
          out.println("Unit Price: " + item.getUnitPrice() + "&lt;br/&gt;");
          out.println("On Stock  : " + item.getOnStock() + "&lt;br/&gt;");
          out.println("&lt;/body&gt;");
          out.println("&lt;/html&gt;");
      } else {
          RequestDispatcher rd =
             request.getRequestDispatcher("/SearchPage.html");
          rd.include(request, response);
          rd = request.getRequestDispatcher("/AddData.html");
          rd.include(request, response);
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I am trying to use the scriplets, but still want to know how to convert:</p>
  
  <pre><code>import java.io.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  </code></pre>
  
  <p>to JSP.  I try to do this:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;title&gt;Display Data&lt;/title&gt;
  &lt;/head&gt;
  &lt;jsp:useBean id="inventory" class="Inventory.AddData" /&gt;
  &lt;jsp:directive.page import="java.io.*" /&gt;
  &lt;jsp:directive.page import="javax.servlet.*" /&gt;
  &lt;jsp:directive.page import="javax.servlet.http.*" /&gt;
  &lt;body&gt;
  
      &lt;%-- But I don't know how to convert this:
           public class DisplayData extends HttpServlet
           in JSP
      --%&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>please Help... thanks in advance</p>