title: Not able to pass value from servlet to JSP
body: <p><strong>Code Updated with web.xml and Servlet configuration</strong></p>
  
  <p>I am trying to forward some value from my servlet to JSP, but when I am trying to access that value into JSP, there is no output.</p>
  
  <p>Here is my form:</p>
  
  <pre><code>&lt;HTML&gt;
  &lt;BODY&gt;
  &lt;FORM METHOD=POST ACTION="servlet/NewServlet"&gt;
  Enter Name: &lt;Input type="text" name="name"/&gt;&lt;br&gt;
  &lt;P&gt;&lt;INPUT TYPE=SUBMIT&gt;
  &lt;/FORM&gt;
  </code></pre>
  
  <p>Here is my Bean I am using for setter and getter methods:</p>
  
  <pre><code>package user;
  
      public class CompileClass {
      public String name;
  
      public void setName(String n){
              name=n;
          }
  
      public String getName(){
              return name;
          }
      }
  </code></pre>
  
  <p>Here is my servlet:</p>
  
  <pre><code>import java.io.*;
  import javax.servlet.*;  
  import javax.servlet.http.*;
  
  import user.CompileClass;
  
  public class NewServlet extends HttpServlet{
  
      public void doPost(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException{
  String name1;
  
  CompileClass c=new CompileClass();
  name1=c.getName();
  request.getSession().setAttribute("name1", name1);
  
  request.getRequestDispatcher("../Result.jsp").forward(request, response);
  
      }
      }
  </code></pre>
  
  <p>And finally here is my JSP page:</p>
  
  <pre><code>&lt;%@ page import="java.net.*"%&gt;
  &lt;%@ page import="javax.servlet.*"%&gt;
  &lt;%@ page import="java.util.ArrayList"%&gt;
  
  &lt;jsp:useBean id="user" scope="request" class="user.CompileClass" /&gt;
  &lt;jsp:setProperty property="*" name="user"/&gt;
  &lt;html&gt;
  
    &lt;body&gt;
  
  Name:
  &lt;br/&gt;
  
  &lt;% request.getSession().getAttribute("name1");%&gt;
  
  
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is my web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.4" 
      xmlns="http://java.sun.com/xml/ns/j2ee" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
      http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;
    &lt;servlet&gt;
      &lt;description&gt;This is the description of my J2EE component&lt;/description&gt;
      &lt;display-name&gt;This is the display name of my J2EE component&lt;/display-name&gt;
      &lt;servlet-name&gt;NewServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;NewServlet&lt;/servlet-class&gt;
    &lt;/servlet&gt;
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;NewServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/servlet/NewServlet&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
    &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Everything seems fine to me. But still I am not getting any output on my JSP page. Help?</p>