• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

syntax...boolean

 
Suka Hati
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to request a boolean value from a form in servlet?
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Request the boolean variable as usual then convert same to boolean.




thanks..
 
Praful Thakare
Ranch Hand
Posts: 642
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
MK Shikarpuri
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Praful,
Thanks for clearing the issue.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's usually cleaner to use "true".equals( request.getParameter("param1") ), it manages null values for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic