• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

how to create insert, update, delete buttons on the same page?

 
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i created a program which has three classes, my program is inserting, updating, deleting, fetching records from database, and my code is working perfectly for me, but i created this for console:

Here is my three classes:
EmpDbComponent.java



Employee.java


Test.java


now what i want is i create a from in html, for these employee records and i have three buttons on the same page (ie. Insert, Update, Delete) how do i call functions of my EmpDbComponent class on each button click..?? all three buttons are on the same form..
 
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you ever written a jsp page before?

if you have made many jsps before what exact problem are you having? if not can I recommend the head first servlets and jsp book, it is a modern classic.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am using servlet here, and the problem is i don't know how to i pass one function of one servlet as a of one button click,
for a single button i just create a from and on the action i pass that servlet. but for multiple buttons how do i do this, although i have same form on my page...
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my question is simply how can i add multiple buttons (ie.add/update/delete) in my form, in which i can use functions of EmpDbComponent on each button call
Test.java is i use for console, but now i m using servlet
here is my servlet i am using for these operations



and this servlet i am calling on a form submit, and i want to perform more operations on the same form, not only displaying how can i do this??
 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I'm understanding your question correctly, one possibility is to assign names to your buttons. Upon form submit, the name of the button will be passed as one of the form parameters and you can use that in the servlet to determine which button was clicked.

Myself, I would use JavaScript to catch the click events and use AJAX to perform the CRUD operations.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well i don't know how to do this with ajax and javascript...
and okay, i assign names to my three buttons, how my servlet will know which button is pressed and which function needs to invoke..??
what i need to do for this??
 
Ranch Hand
Posts: 171
Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any request which hits servlet, will be processed by get() or post() which is depends on your form submit method. You have to set a html element to indicate which element has been clicked(this is very basis idea to use)so that it would send to servlet as a parameter. Based on the flag you can process call your method.
 
J. Kevin Robbins
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The name and value of the button that is clicked will be passed as a request parameter. Look at the docs for request.getParameterNames(). Loop through that enumeration checking for your button names and branch accordingly.
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The button mane will be part of the request parameters.

Wendy is correct. You need to go back and do some reading. This sort of thing is a very basic concept in JSP and servlets and will be covered in any good book on the subject.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
okay...thanks
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
shihab shahriar,
Your post was moved to a new topic.
 
Screaming fools! It's nothing more than a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic