I'm new to Java server programming, and I'm trying to use Google app engine.
The following code is in a servlet:
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
req.setAttribute("message", "Hi from servlet!");
req.getRequestDispatcher("/my_page.jsp").forward(req, resp);
}
And the following code is in my_page.jsp
:
<%= request.getAttribute("message") %>
Where I would expect to see Hi from servlet!
on the resulting page, I see null
.
(If I try using ${message}
, I get no output at all)
What is the correct way to get data from a servlet to a JSP?