This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes communication between servlets & JSPs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "communication between servlets & JSPs" Watch "communication between servlets & JSPs" New topic
Author

communication between servlets & JSPs

Chandrasekhar Nadella
Greenhorn

Joined: Feb 07, 2001
Posts: 7
can i use jsp:usebean tag in javascript function loop?
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
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).]


<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
Chandrasekhar Nadella
Greenhorn

Joined: Feb 07, 2001
Posts: 7
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

Joined: Oct 12, 2000
Posts: 124
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

Joined: Jul 17, 2000
Posts: 124
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

Joined: Apr 02, 2001
Posts: 1157
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

Joined: Feb 07, 2001
Posts: 7
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: communication between servlets & JSPs