title: Getting null value on request.getAttribute
body: <p>Hi I have a servlet class like this</p>
  
  <pre><code>public class DBConnection extends HttpServlet {
     protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException 
     {
  
        resp.setContentType("text/html");
        req.setAttribute("Message","Message from servlet page");
  
        req.getRequestDispatcher("/index.jsp").forward(req,resp);
  
     }
  }
  </code></pre>
  
  <p>calling servlet on index.jsp page like this</p>
  
  <pre><code>&lt;% String Msg= (String)request.getAttribute("Message");
  out.println("&lt;p&gt; Servlet communicated message to JSP: "+ Msg + "&lt;/p&gt;");%&gt;
  </code></pre>
  
  <p>This in my web.xml file</p>
  
  <pre><code>&lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"&gt;
      &lt;display-name&gt;dbconnection&lt;/display-name&gt;
      &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;Login.html
      &lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;DBConnection&lt;/servlet-name&gt;
          &lt;servlet-class&gt;DBConnection&lt;/servlet-class&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;DBConnection&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/DBConnection&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>I am getting a null value .. can anyone help me?</p>