File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes checkbox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "checkbox " Watch "checkbox " New topic
Author

checkbox

Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 483

Hi ,
Is it possible to check in a servelt if a checkbox is checked or not , note : the checkbox is in a jsp.. ?


Thanks,
Sherif
Mohamed Inayath
Ranch Hand

Joined: Nov 22, 2004
Posts: 124
If JSP has a form and is submitted to the servlet then YES.
Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 483

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

Joined: Feb 10, 2001
Posts: 641
in html (jsp)


In Servlet



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

-P


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
Mohamed Inayath
Ranch Hand

Joined: Nov 22, 2004
Posts: 124
JSP :


Servlet :

Hope this will answer your query?

Also :

The response will be like as Praful Thakare has updated.

Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 483

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

Joined: Nov 22, 2004
Posts: 124
Deploy and run the given example and you will get your answer.
Also no need to have the value attribute.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Jan 28, 2008
Posts: 5575

@ Mohamed



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

Joined: Nov 22, 2004
Posts: 124
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

Joined: Mar 05, 2007
Posts: 483

Thanks Guys for help
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: checkbox