Reputation: 23
<%String dest = request.getParameter("destination").toUpperCase();%>
Hello...
I got a little bit problem here. I am using the above code to get value from form. When use the code without toUpperCase()
, it was a success. But, when I add toUpperCase()
I got HTTP Status 500 - An exception occured processing JSP page
.
Upvotes: 1
Views: 1377
Reputation: 8387
When you get value null
from request.getParameter("destination")
, apply toUpperCase()
to a null
value gives an error.
Try to do like this:
<%String dest = request.getParameter("destination");
if(dest!=null){
dest = dest.toUpperCase();
}
%>
The request.getParameter() returns String value or a null value from client.
Upvotes: 1
Reputation: 647
More than likely, request.getParameter("destination")
is returning null
in your code, which would be why it's throwing an error. If the parameter is not found, then null
is returned, otherwise a String
is returned.
So you'll want to verify that it's not null
<% String dest = request.getParameter("destination");
if(dest != null) {
dest = dest.toUpperCase();
}
%>
Upvotes: 0