Reputation: 13
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setAttribute("orden", 11);
System.out.println("ord "+request.getParameter("orden"));//returns null
request.getRequestDispatcher("/view/a.jsp").forward(request, response);
}
//Why does this happen?
and in my jsp is the same result = null
Upvotes: 1
Views: 33
Reputation: 8796
You are setting an attribute
and trying to get a parameter
request.setAttribute("orden", 11);
request.getAttribute("orden");
Upvotes: 1
Reputation: 8322
attribute and parameter are different things. As you are setting attribute, use getAttribute() to get the value.
System.out.println("ord "+request.getAtribute("orden"));
Upvotes: 0