In my web application I have a link - "Create New User". From the jsp I am sending some request to the server like -
<div style="float:right" class="view">
<a href="/some/url/createUserMVC.do?hasCreatePermission=${user.hasPermission['createUser']}">Create New User</a>
</div>
Here user.hasPermission[] is an array of boolean. If the current user (that is user ) has the permission(that is 'createUser') to create an new user than it returns true.
Now from my controller I am trying to get the value from the request parameter, like -
request.getParameter("hasCreatePermission");
But the problem is request.getParameter() returns a String. So how can I get the boolean value from the parameter. There is no overloaded version of request.getParameter() method for boolean.
I don't think it is possible. Request is always String content. But you can do
boolean hasCreatePermission= Boolean.parseBoolean(request.getParameter("hasCreatePermission"));
If you are sure it's a boolean you can use
boolean value = Boolean.valueOf(yourStringValue)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With