Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing form values

Status
Not open for further replies.

rabix

Programmer
Apr 23, 2001
12
CH
hi all,
i got a jsp page with a check box in it. how can i check whether it is checked or not in another jsp page?
rgds,
Rabix
 
hi

use a "name" attribute in your html check box tag.
assign it a value.

then you can retrieve the value of the check box field using the "request" implicit variable.

ex :

jsp 1

<html-tag-for-a-check-box name=&quot;mycheckbox&quot;> </...>

jsp 2

<%
if( request.getParameter(&quot;mycheckbox&quot;).equals(&quot;???&quot;) {

// do something

}
else {

// do other thing
}
%> manu0
 
Checkboxes submit a value only when they are checked.
Example:

HTML
Code:
<INPUT TYPE=&quot;CHECKBOX&quot; NAME=&quot;cbox&quot;>

JSP
Code:
if (request.getParameter(&quot;cbox&quot;) != null && !request.getParameter(&quot;cbox&quot;).trim().equals(&quot;&quot;)) {

   /* Checkbox is checked */

}
else {

   /* Checkbox is not checked */

}

Hope that helps.
Wushutwist
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top