Meaningless Drivel is fun!
The moose likes Servlets and the fly likes syntax...boolean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "syntax...boolean" Watch "syntax...boolean" New topic


Suka Hati
Ranch Hand

Joined: Oct 28, 2004
Posts: 56
how to request a boolean value from a form in servlet?
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1082

Request the boolean variable as usual then convert same to boolean.


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 642
You can use Shailesh's with changing value of param1 to "true" or "false"
before submitting the form,or use alternate as

<input type=checkbox name=param1> // This will be placed in Form

and in Servlet chek it as

boolean b=false;


NOTE:- if checkbox is not selected then request.getParameter("param1") will return null

Hope This Helps

All desirable things in life are either illegal, banned, expensive or married to someone else !!!
MK Shikarpuri

Joined: Jan 21, 2004
Posts: 9
Thanks for clearing the issue.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

It's usually cleaner to use "true".equals( request.getParameter("param1") ), it manages null values for you.
subject: syntax...boolean
It's not a secret anymore!