Hi I have a servlet class like this
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);
}
}
calling servlet on index.jsp page like this
<% String Msg= (String)request.getAttribute("Message");
out.println("<p> Servlet communicated message to JSP: "+ Msg + "</p>");%>
This in my web.xml file
<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">
<display-name>dbconnection</display-name>
<welcome-file-list>
<welcome-file>Login.html
</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>DBConnection</servlet-name>
<servlet-class>DBConnection</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DBConnection</servlet-name>
<url-pattern>/DBConnection</url-pattern>
</servlet-mapping>
</web-app>
I am getting a null value .. can anyone help me?