Reputation: 41
I don't know how to check if my parameter is null. How?
http://localhost:8080/msg?fn=Igor&sn=Jedna&id=2
http://localhost:8080/msg?p_r=null&fn=Igor&sn=Jedna&id=2
My code not working:
<% if (request.getParameter("p_r").equals("null")) {
//do stuff with p_r
}
%>
AND
<% if (request.getParameter("p_r").equals(null)) {
//do stuff with p_r
}
%>
org.apache.jasper.JasperException: An exception occurred processing JSP page
How can I check it?
Upvotes: 2
Views: 524
Reputation: 2675
First, check that param exists.
For example;
<%
if(request.getQueryString().contains("p_r=")){
if (request.getParameter("p_r").equals("null")) {
out.print("p_r is null.");
}
}
%>
Upvotes: 1
Reputation: 6533
Try this:
<% if (request.getParameter("p_r") == null) {
//it is null. do null-handling
}
%>
Upvotes: 0