File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending checkbox value to two different servlet page

 
Nitin Belaram
Ranch Hand
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On onclick


 
ash chowdary
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



try like this...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic