Reputation: 327
In my URL if the user enters in Type I have the following code:
String type= (request.getParameter("Type") != null) ? request.getParameter("Type") : request.getParameter("ty");
I would like to ignore the case that the user entered. For example a use case can be that the user enters Type, TYPE, TyPe, TYpe, tyPe, or Ty, tY, TY, ty. I want that to just to ignore the case have have it be set with my code. I tried to convert it to lower case but it did not work I get an error. Here is what I tried.
String type= (request..toLowerCase().getParameter("Type") != null) ? request.getParameter("Type") : request.getParameter("ty");
This did not work.
Upvotes: 0
Views: 1978
Reputation: 160261
Converting a request to lower-case doesn't make any sense. Converting a string to lower case does.
In any case, I think what you're asking is to get a list of parameters, e.g.,
ServletRequest.html#getParameterNames()
Enumeration<String> paramNames = request.getParameterNames();
Then iterate over that list of parameter names, call toLowerCase()
on them, and make comparisons as your business logic dictates.
You might also use getParameterMap()
which does what you'd expect.
Upvotes: 2