aspose file tools*
The moose likes Servlets and the fly likes How to trace selected CheckedBoxes in different forms using a Single Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to trace selected CheckedBoxes in different forms using a Single Servlet" Watch "How to trace selected CheckedBoxes in different forms using a Single Servlet" New topic
Author

How to trace selected CheckedBoxes in different forms using a Single Servlet

Faraz Masood
Ranch Hand

Joined: May 03, 2002
Posts: 55
hi
i had a servlet called createReceipt which will take the selected inputs from three different HTML forms and generate the receipt .
i need to know about ne such pattern which will help me in taking the inputs from the forms
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
If I understand you correctly, you want to get the values of the check boxes that are checked. You can just use getParameter. if a checkbox is not checked, it will not be returned at all. i.e.null will be returned.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Faraz Masood
Ranch Hand

Joined: May 03, 2002
Posts: 55
let me more specific
while trying to make a Shopping cart application i came across this problem
that there are three different (html)forms for three different departments,
a user can move back and forth at will , selecting the items (NOT
DESELECTING) that were there in the form of checkboxes.
and hits checkout button whenever he wants to logout(checkout button can be
hit from any form ) , then we have to display a page containg information
about the purchased goods.
my quesion is how can we trace the selected options of different chechboxes
in three different forms ???
Saravanan Viswanathan
Greenhorn

Joined: Oct 16, 2001
Posts: 20
Hi
U can have one name(test1) for all the checkboxes in one HTML Form.then u can get the values thru request.getParameterValues("test1") which will give the values of all the Selected checkboxes.
Ex:-
1.html
<input type="checkbox" name="test1" value="100" />
<input type="checkbox" name="test1" value="200" />
Hope this helps.
Saravanan Viswanathan.
mustang india
Ranch Hand

Joined: Feb 05, 2002
Posts: 60
HI Faraz,
U cannot directly navigate form one html to other, u have to go thru a servlet. I mean , when u select items in one html, if u go directky to another servlet, the data is lost as http is stateless protocol. What u have to do is, from 1st html, go to a servlet, store the data in a session and let the servlet redirect you to the next html. I hope u got the point.
why dont u consider using JSP ?
Regards,
Mustang.
Faraz Masood
Ranch Hand

Joined: May 03, 2002
Posts: 55
finally i got the job done
but no JSPs because we had to make that without using JSP
Thanks for the help
 
Don't get me started about those stupid light bulbs.
 
subject: How to trace selected CheckedBoxes in different forms using a Single Servlet