I didn't have trouble with this before, and I actually have a working implementation with a different class. But for some reason, this example fails.
I have a class called InfoServlet.java
:
@WebServlet("/info_servlet")
public class InfoServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setAttribute("test", "hello world.");
request.getRequestDispatcher("info_servlet.jsp").forward(request, response);
}
}
And my jsp page info_servlet.jsp
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
</head>
<body>
<h1>HELLO</h1>
<p><c:out value="${test}" /></p>
</body>
</html>
Now when I go to localhost:8080/MySite/info_servlet.jsp
my output is only
HELLO
For reference, I'm using tomcat 7 and servlet 3.0 in java. I didn't have trouble passing in an object so I'm unsure why all the sudden it won't let me display the value in info_servlet.jsp