Checking to see if request.getParameter("myparam") exists


S

Steveo

I'm new to java and JSPs. I was wondering if there is an easy way to
check if a parameter exists. I need to handle the page differently if
the parameter is not there.

Thanks
 
Ad

Advertisements

R

Roedy Green

I'm new to java and JSPs. I was wondering if there is an easy way to
check if a parameter exists. I need to handle the page differently if
the parameter is not there.

does it not just return null if it is missing?
 
Ad

Advertisements

M

Michiel Konstapel

Steveo said:
I'm new to java and JSPs. I was wondering if there is an easy way to
check if a parameter exists. I need to handle the page differently if
the parameter is not there.

if (request.getParameter("name") == null) {
// it's not there
}

I still think request.hasParameter("name") would have been nice to have.
Oh well.
Michiel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top