Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
JSP CheckBox 
 

JSP CheckBox is used to create a CheckBox in JSP.

 

JSP CheckBox

                          

JSP CheckBox is used to create a CheckBox in JSP. The JSP Page allows the user to select more than one option from multiple checkbox and also print the userdefined message that specify the languages option choosen by the user on submitting the button.

Understand with Example

The Tutorial illustrate an elaborate example from 'JSP CheckBox'. To understand and grasp the example we create a CheckBox.jsp that include the html tag<input type="checkbox"> to create the checkboxes. The HTML page allows the user to select multiple languages using checkbox.  After submitting the button, the action is performed which display the selected languages. The method request.getParameter Values("id") is used to return the value of selected checkbox. The for loop is used to execute the code repeatedly till the length of variable i is less than equal to select position of checkbox. Finally the out.println is used to print the selected checkbox in the browser.

Here is the code of jspCheckBox.jsp

<html>
<h2>Select Languages:</h2>

<form ACTION="jspCheckBox.jsp">
<input type="checkbox" name="id" value="Java"> Java<BR>
<input type="checkbox" name="id" value=".NET"> .NET<BR>
<input type="checkbox" name="id" value="PHP"> PHP<BR>
<input type="checkbox" name="id" value="C/C++"> C/C++<BR>
<input type="checkbox" name="id" value="PERL"> PERL <BR>
<input type="submit" value="Submit">
</form>
<%

String select[] = request.getParameterValues("id"); 
if (select != null && select.length != 0) {
out.println("You have selected: ");
for (int i = 0; i < select.length; i++) {
out.println(select[i]); 
}
}
%>
</html>

Output will be displayed as:

After selecting the languages, when you submit the button, the message will be displayed with selected languages:

Download Source Code:

                          

» View all related tutorials
Related Tags: c jsp ide variables script io methods scope count method variable ip page vi number lock ole int ria this

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.