aspose file tools*
The moose likes Servlets and the fly likes Sending checkbox value to two different servlet page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Sending checkbox value to two different servlet page" Watch "Sending checkbox value to two different servlet page" New topic
Author

Sending checkbox value to two different servlet page

Nitin Belaram
Ranch Hand

Joined: Mar 24, 2009
Posts: 67
I had a jsp page in which i had two button delete and update ,
The user select checkbox and after clicking delete button record are deleted from database for which i had defined servlet which is working fine it is getting value of check box as i had define form action to call delete servlet. the input type of delete button is submit.

Q) How can i pass value of check box from same jsp page to another servlet where i can update my record ,
Q) How can i had two submit button on same page OR how to submit checkbox value without using submit button to servlet

My JSP code
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3829

Nitin Belaram wrote:
Q) How can i pass value of check box from same jsp page to another servlet where i can update my record ,
Q) How can i had two submit button on same page OR how to submit checkbox value without using submit button to servlet


You can have several buttons (of type "button") and submit them through Java Script function when clicked. Or if you don't want to submit the hole page you may send the data through AJAX.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Mohamed Inayath
Ranch Hand

Joined: Nov 22, 2004
Posts: 124
Nitin,

Q) How can i pass value of check box from same jsp page to another servlet where i can update my record ,


Update: you to have all the values from the screen along with checkbox value to the UpdateServlet.
(Similar way you have done in Delete Servlet).

Q) How can i had two submit button on same page OR how to submit checkbox value without using submit button to servlet


Yes you can have two Submit Buttons.

Create a hidden parameter say userSelect within the form.
Set the value for userSelect when the user selects either Delete/Update.

Without submit button; tell me at what user event you want to pass the values of the screen to servlet.

Nitin Belaram
Ranch Hand

Joined: Mar 24, 2009
Posts: 67
Mohamed Inayath wrote:Nitin,

Q) How can i pass value of check box from same jsp page to another servlet where i can update my record ,


Update: you to have all the values from the screen along with checkbox value to the UpdateServlet.
(Similar way you have done in Delete Servlet).

Q) How can i had two submit button on same page OR how to submit checkbox value without using submit button to servlet


Yes you can have two Submit Buttons.

Create a hidden parameter say userSelect within the form.
Set the value for userSelect when the user selects either Delete/Update.



The JSP page code is fetching the record from database and displaying them in table, from where i can either delete the record or update them on the basic of checkbox.
Delete is working fine as i had define input type submit and form action as delete servlet.

But how can i update the record, on click of a button i want to pass empid to my servlet where i can call my update method defined in controller servlet.

Q) how does hidden parameter will work

Without submit button; tell me at what user event you want to pass the values of the screen to servlet.

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

On onclick


ash chowdary
Greenhorn

Joined: Apr 23, 2009
Posts: 16



try like this...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sending checkbox value to two different servlet page