I have a very simple JSP file, which more or less displays a get variable.
<p>Hello, <%= request.getParameter("name") %></p>
So, if I go to webpage.jsp?name=Alice
, I'd get Hello, Alice
. If I just go to webpage.jsp
on the other hand, I get Hello, null
.
If the name variable is not set, I would like to send a Bad Request instead. In a servlet I'd do this:
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
How can I do similarly from a JSP page?