I am opening in browser link mapped to my servlet, and expect to display the passed value. But what i see is "null"
Servlet:
public class TestServlet extends HttpServlet {
public TestServlet() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setAttribute("var", "a");
request.getRequestDispatcher("index.jsp").forward(request, response);
}
}
jsp:
<%
String s1 = (String) session.getAttribute("var");
%>
<%= s1 %>