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
 
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?
 
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

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top