• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to interact with database using servlet

 
Avinash Nethi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Sir,
I want to interact with database in servlet program
can you please give me an example

My task is i have to enter three fields using form namely employee_id, employee_name and employee_mobile number with a submit button
By pressing the submit button the records which i have entered in the form is to be inserted in the database please help me sir
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15644
48
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, create a web page with an HTML form. Then, create a servlet. Make the action of the form on the web page refer to the URL of the servlet, so that the form is submitted to the servlet. Set the method attribute of form to "POST".

In the servlet, implement a doPost() method. Use request.getParameter(...) to get the information that's in the submitted form. Use JDBC to insert the information into a database.

You can find tutorials about servlet programming or JDBC on Internet, or in a book like Head First Servlets & JSP.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic