aspose file tools*
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
Author

syntax...boolean

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: 1081

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




thanks..


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

Joined: Feb 10, 2001
Posts: 637
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;

if(request.getParameter("param1")!=null)
b=true;

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

Hope This Helps
Cheers
-Praful


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

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

Joined: Mar 06, 2001
Posts: 13459

It's usually cleaner to use "true".equals( request.getParameter("param1") ), it manages null values for you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: syntax...boolean