I'm creating a jsp form, once they submitted in the servlet i have to check whether the form is set or not. In PHP i use to check with the ISSET function same like how i can do it in Servlet??
Another (in my sense more expressive) construct would be
request.getParameterMap().containsKey("paramname")
as shown here
In servlets you can check using getParameter method of Request Object
if(Request.getParameter("Submit")!=null)
{
...
...
}
Servlet's request.getParameter()
is used to return the value of a request parameter passed as query string and posted data which is encoded in the body of request.
This method is provided by the interface ServletRequest
which returns the value of a request parameter as a String, or null if the parameter does not exist. The method request.getParameter()
retrieves the passed parameters and displays the value of the parameters on the browser.
Servlet equivalent of PHP isset($_REQUEST['paramname'])
is
if (request.getParameter("paramname") != null) {
// Parameter is set.
}
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