Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

communication between servlets & JSPs

 
Chandrasekhar Nadella
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i use jsp:usebean tag in javascript function loop?
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I think, it is not a problem, but what do you want to achieve?.<jsp:usebean> tag is a action tag which is meant for the entire page, so where ever you define in the page, it will not make a difference.
Are you looking to create multiple instances by putting the action tag in the loop?
Regards,
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56

  5. [This message has been edited by Desai Sandeep (edited April 26, 2001).]
 
Chandrasekhar Nadella
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes..I have html table in jsp, which has the check boxes in the first column and a delete button. I want to delete all the rows from the database for which the chk box is checked. So on click of delete button i want to loop thru the chk boxes and delete the rows from the DB using delete method in java bean. Hope i conveyed my question properly..
Thanks for the reply..
 
Bhupinder Dhillon
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chandrasekhar Nadella:
yes..I have html table in jsp, which has the check boxes in the first column and a delete button. I want to delete all the rows from the database for which the chk box is checked. So on click of delete button i want to loop thru the chk boxes and delete the rows from the DB using delete method in java bean. Hope i conveyed my question properly..
Thanks for the reply..

And what does it have to do with JavaScript?? What you want to do is submit the form and then delete the rows on the server. Where does javascript fit into all this?
 
Ashwin Desai
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
As far as I understand your problem, you can use the remove() method of the bean in a javascript loop. But, you would need to make a separate call to the bean for each row to be deleted.
Another way is to pass on details (like unique IDs etc )for the selected rows to the bean in a single method call and have the bean delete them in the same method.
Ashwin.
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Chandrasekhar,
I think,for the functionality that you have mentioned, you donot require JavaScript.
What you would need to do is, to trap the records you want to delete and pass it to your DeleteForm JSP/Servlet, which inturn calls a Bean(say DeleteRecordBean) which has a remove/delete the record from the Database.
To be more specific, when you select say 2 checkboxes, and hit the Delete button, you post the information to the Servlet say DeleteForm, which gets the records you selected, by using the following code:

After that, you could iterate through, the array and call the Bean's remove/delete method to remove the records from the Database.It is shown in the code below:

The remove() method in yourBean JavaBean has simple JDBC calls to remove the record from the Database.
Hope this helps.
Regards,
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56

  5. [This message has been edited by Desai Sandeep (edited April 26, 2001).]
 
Chandrasekhar Nadella
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all for ur help...What I have done is added a hidden fld 'keylist' to form to contain the keys of all rows to be deleted. and in server i'm parsing the keys and deleting the rows with the bean delete method. Hope it doesn't degrade any performance suggest me please.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic