This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

checkbox

 
Sherif Shehab
Ranch Hand
Posts: 485
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
Is it possible to check in a servelt if a checkbox is checked or not , note : the checkbox is in a jsp.. ?
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If JSP has a form and is submitted to the servlet then YES.
 
Sherif Shehab
Ranch Hand
Posts: 485
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohamed Inayath wrote:If JSP has a form and is submitted to the servlet then YES.

ya the jsp has a form , can you please show me an example ?
 
Praful Thakare
Ranch Hand
Posts: 642
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in html (jsp)


In Servlet



if this returns null then check box is not selected else it is.

-P
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP :


Servlet :

Hope this will answer your query?

Also :

The response will be like as Praful Thakare has updated.

 
Sherif Shehab
Ranch Hand
Posts: 485
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Praful Thakare wrote:in html (jsp)


In Servlet



if this returns null then check box is not selected else it is.

-P

as i saw on some examples on the net , i think we need to add "value" attribute so if it's null this means not checked else means checked , am i right ?
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deploy and run the given example and you will get your answer.
Also no need to have the value attribute.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sherif Shehab wrote:
as i saw on some examples on the net , i think we need to add "value" attribute so if it's null this means not checked else means checked , am i right ?


personally i use value attribute,but is not mandatory.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ Mohamed



the charset attribute is new to me . i guess better to use ISO-8859-1 or UTF-8
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seetharaman venkatasamy wrote:@ Mohamed



the charset attribute is new to me . i guess better to use ISO-8859-1 or UTF-8


Good to use UTF-8 since windows-1252 is the superset of ISO-8859-1.

 
Sherif Shehab
Ranch Hand
Posts: 485
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Guys for help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic