Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet storing details in database on clicking submit button
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


teja
storing details in database on clicking submit button
1 Answer(s)      5 years ago
Posted in : JSP-Servlet


I am using JSP in NetBeans and have developed an application form which has fileds naming 'Name' and 'ID'.I want to store the details of these two fields in the MYSQL database on clicking submit button. I am unable to do this.Can u tell me how to code this page and where and should be my code written?

This is my simple code...Tell me where an what code should I write to store the values in data base table?

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
Name:<input type="text" name="name" value="" size="10" /><br><br>
ID:<input type="text" name="id" value="" size="10" /><br><br>
<input type="submit" value="Submit" name="submit" />
</body>
</html>

Advertisement
View Answers

April 6, 2010 at 4:14 PM


Hi Friend,

Try the following code:

<%@page import="java.sql.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<form method="post">
<table>
<tr><td>ID:</td><td><input type="text" name="id" value="" size="10" /></td></tr>
<tr><td>Name:</td><td><input type="text" name="name" value="" size="10" /></td></tr>
<tr><td><input type="submit" value="Submit" name="submit" /></td></tr>
</table>
</form>
</html>
<%
String id=request.getParameter("id");
String name=request.getParameter("name");
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root";, "root");
Statement st=connection.createStatement();
int i=st.executeUpdate("insert into data(id,name) values('"+id+"','"+name+"')");
out.println("inserted successfully");
}
catch(Exception e){}
%>

Thanks


Related Tutorials/Questions & Answers:
storing details in database on clicking submit button - JSP-Servlet
storing details in database on clicking submit button  I am using JSP... 'Name' and 'ID'.I want to store the details of these two fields in the MYSQL database on clicking submit button. I am unable to do this.Can u tell me how to code
Submit button to MySQL database?
Submit button to MySQL database?  Need help linking html code to mysql database <html> <head> <meta http-equiv="Content-Type...="text" name="Level" /> </form> <td><input type="submit
Advertisements
Submit button to MySQL database?
Submit button to MySQL database?  Need help linking html code to mysql database <html> <head> <meta http-equiv="Content-Type...="text" name="Level" /> </form> <td><input type="submit
create text box by clicking button and submittong text in text box using submit
create text box by clicking button and submittong text in text box using submit  Hi, I created a button when i click on button new textbox... will click submit button the text should be submitted(it shows the value in text
submit button
submit button  <p>hi I am trying to insert record in database using hibernate in JSP(Netbeans). When I click insert button it should go...; <input type="submit" value="Insert" name="login" /> <
How to save form fields into the MySql Database without submit button in jsp?
How to save form fields into the MySql Database without submit button in jsp?  I want to store user inputs into the database using javasccript or ajax or jqury but without submit button. Form Contains three fields
Submit comments in database when user clicks on submit button
Submit comments in database when user clicks on submit button... database when user clicks the submit button of the page. Create a database: First... be integer number then click submit button. If all the values are submitted
JSP Submit Button
JSP Submit Button  Sir, I have a JSP page with 2 Submit button, both calls doPost method of same servlet. If I click any submit button the text box value get refreshed and set to null or blank, that should not happen. Plz help
autogeneration of a random number and displaying it as a alert message to the user on clicking submit
on the submit button as a "alert message" and this refrence number act as primary key... is generated it should be inserted into database along with the details of addform when... to the user on clicking submit  Hi, In my project order purchase system under
storing csv into oracle database
storing csv into oracle database  i want jsp code for storing csv file into oracle database
image on submit button
image on submit button  i need to set an image on submit button. In javascript we can create a button like.. <a href="javascript:;" class="button...: transparent; cursor: pointer; or input[type=submit] { background: transparent
Get specific item details by clicking on hyperlink
Get specific item details by clicking on hyperlink  sir, I am... button, if I click on that button it lists all items with item name and corresponding image with a hyperlink on it from the database to a jsp page. -If I click
after entering details in reg page,n enter the submit button,how can v store the data in db, n hw can v retrive the data frm db in jsp
after entering details in reg page,n enter the submit button,how can v store... registration page n login page. after entering details in reg page,n enter the submit button,how can v store the data in db, n hw can v retrive the data frm
Uploading a Software and storing in the database
Uploading a Software and storing in the database  I want to upload a software(may be of maximum 20mb) through JSP, and store it in the database. The coding present in the site for uploading and storing in the database
How to show multiple identicle rows from database on clicking search button to jtable
How to show multiple identicle rows from database on clicking search button to jtable  Hello Sir, I made search button with textfield... and show multiple identical rows from database on clicking search button
How to show multiple identicle rows from database on clicking search button to jtable
How to show multiple identicle rows from database on clicking search button to jtable  Hello Sir, I made search button with textfield... and show multiple identical rows from database on clicking search button
How to show multiple identicle rows from database on clicking search button to jtable
How to show multiple identicle rows from database on clicking search button to jtable  Hello Sir, I made search button with textfield... and show multiple identical rows from database on clicking search button
storing xml into database - XML
storing xml into database   hi i have an xml file it contains elements with attributes as well as nested elements so how to go forward .......with it i know how to persist a simple xml file into data base but i m finding some
How to Display Next question from database after clicking Next Button using "Arraylist concept"
How to Display Next question from database after clicking Next Button using "Arraylist concept"  </tr> <%if (pageName.equals("1")) {%> <tr> <td> <div style
Disabling submit button using jQuery
Disabling submit button using jQuery  Hello Sir I want to know - is there any way or approach to disable client side form's "Submit" button. Please give code also.   For all submit buttons, via JQuery, it'd
On Click on Submit Button Display Data on Orderlist
On Click on Submit Button Display Data on Orderlist  How can retreive data from database on orderlist on Click on submit Button of same page
How can we submit a form without a submit button?
How can we submit a form without a submit button?  How can we submit a form without a submit button
Struts application two submit button
;/html> Here am using two submit button one is login and another one is new...Struts application two submit button  Hai, i'm new in struts...;html:submit tabindex="6" styleClass="btTxt"> <bean
Hide text by clicking button
Hide text by clicking button In this tutorial, we will discuss about hide/show text by clicking on button. In the below example, there are two buttons... the animation will run OUTPUT Before clicking any button : After click "
Click On Images of Submit Button Perform Action
Click On Images of Submit Button Perform Action  I have login page in which insert of submit button i used image. Therefor on Click of image i have to validate form , link with database and goto the next page
Compose mail by clicking on send mail button
Compose mail by clicking on send mail button  How i get microsof out look page opend for composing mail by just clicking on send mail button and when outlook page open then in to:my email id is written on my jsp page
Should not logout after clicking the back/forward button
Should not logout after clicking the back/forward button  Hi all I... he clicks on the back button user automatically gets logged out. very next if clicked the forward button user gets logged in..!! how can I solve this issue? What
to fetch data from ms word and storing into database
to fetch data from ms word and storing into database  i want to know how to fetch datafields from ms word and storing into database??? please answer soon .its urgent
Storing records of a file inside database table in java
Storing records of a file inside database table in java  Here is my... surya 25 4 3 ashok 27 I have to display a browse button and whenever user selects student.csv and clicks on submit button, i have to store
getting and storing dropdown list in database in jsp
getting and storing dropdown list in database in jsp  i have a drop down list to select book from database. i'm able to retrieve dropdown list from... lyk this. but it storing null value in the database. :\ what to do
Toggle hide/show by clicking same button
Toggle hide/show by clicking same button In this tutorial, we will discuss about how to toggle hide/show by clicking button. In the given below 2 example, there is button ,by clicking on it, the paragraph will hide/show . In first
Advertisements
 

 

 

DMCA.com