Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

Fresher Job


Search Host

Monthly Fee($)
Disk Space (MB)
Register With us for Newsletter!
Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Have tutorials?
Add your tutorial to our Java Resource and get tons of hits.

We offer free hosting for your tutorials. and exposure for thousands of readers. drop a mail


Java Server Pages


Java Beans



Java Servlets



Java Code Examples

Interview Questions

Join For Newsletter

Powered by groups.yahoo.com
Visit Group! Post Questions!

Web Promotion

Web Submission

Submit Sites

Manual Submission?

Web Promotion Guide

Hosting Companies

Web Hosting Guide

Web Hosting


Beginner Guide to Linux Server


Persistence Framework

Web Frameworks

Free EAI Tools

Web Servers

Aspect Oriented Programming

Free Proxy Servers


Adware & Spyware Remover

Open Source Softwares

inserting value
Expert:kushal BANSAL
<p>sir i want to create a web application when we use the jsp inserting the value in the jsp after that i want these value inserted the database mySQl with the help of servlet. Inserting form data </p>
Inserting form data into database using JSP and Servlet<br /><br />Given code will illustrate you, how one can get data into database using JSP and Servlet<br /><br />Example Code...<br /><br />insertData.jsp<br /><br />&lt;html&gt;<br />&lt;head&gt;<br />&lt;title&gt;Insert value in database&lt;/title&gt;<br />&lt;/head&gt;<br /><br />&lt;body&gt;<br /><br />&lt;table border=&quot;1&quot; width=&quot;50%&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;<br /> &lt;tr&gt;<br /> &lt;td width=&quot;100%&quot;&gt;<br /> &lt;h1&gt;&lt;center&gt;Insert value in Database&lt;/center&gt;&lt;/h1&gt;<br /> &lt;form method=&quot;POST&quot; action=&quot;InsertAction.jsp&quot;&gt;<br /> <br /> &lt;table border=&quot;1&quot; width=&quot;100%&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;<br /> &lt;tr&gt;<br /> &lt;td width=&quot;50%&quot; valign=&quot;right&quot;&gt;&lt;b&gt;Name:&lt;/b&gt;&lt;/td&gt;<br /> &lt;td width=&quot;50%&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;username&quot; size=&quot;30&quot;&gt;&lt;/td&gt;<br /> &lt;/tr&gt;<br /> &lt;tr&gt;<br /> &lt;td width=&quot;50%&quot; valign=&quot;right&quot;&gt;&lt;b&gt;Job-Position:&lt;/b&gt;&lt;/td&gt;<br /> &lt;td width=&quot;50%&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;jobposition&quot; size=&quot;30&quot;&gt;&lt;/td&gt;<br /> &lt;/tr&gt;<br /> &lt;tr&gt;<br /> &lt;td width=&quot;50%&quot; valign=&quot;right&quot;&gt;&amp;nbsp;&lt;/td&gt;<br /> &lt;td width=&quot;50%&quot; valign=&quot;right&quot;&gt;&amp;nbsp;&lt;/td&gt;<br /> &lt;/tr&gt;<br /> &lt;/table&gt;<br /> &lt;p&gt;&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;B1&quot;&gt;<br /> &lt;input type=&quot;reset&quot; value=&quot;Reset&quot; name=&quot;B2&quot;&gt;&lt;/p&gt;<br /> &lt;/form&gt;<br /> &lt;/td&gt;<br /> &lt;/tr&gt;<br />&lt;/table&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;<br />- - - - - - - <br />InsertAction.jsp<br /><br />&lt;%@ page language=&quot;java&quot; import=&quot;java.sql.*&quot; %&gt;<br />&lt;%<br /><br /><br />Connection con = null;<br /> String url = &quot;jdbc:<a href="mysql://localhost:3306/&quot"; target="_blank">mysql://localhost:3306/&quot</a>;;<br /> String db = &quot;register&quot;;<br /> String driver = &quot;com.mysql.jdbc.Driver&quot;;<br /> try{<br /> Class.forName(driver);<br /> con = DriverManager.getConnection(url+db,&quot;root&quot;,&quot;root&quot;);<br /> try{<br /> Statement st = con.createStatement();<br /> String username=request.getParameter(&quot;username&quot;);<br /> String jobposition=request.getParameter(&quot;jobposition&quot;);<br /> int val = st.executeUpdate(&quot;insert user_details values('&quot;+username+&quot;','&quot;+jobposition+&quot;')&quot;);<br /> con.close();<br /> out.println(&quot;success&quot;);<br /> }<br /> catch (SQLException s){<br /> System.out.println(&quot;SQL statement is not executed!&quot;);<br /> }<br /> }<br /> catch (Exception e){<br /> e.printStackTrace();<br /> }<br /><br />%&gt;<br /><br />This will help you to create a small application that will insert the HTML form data into database using JSP and Servlet.<br /><br />
More Questions
Post Answers
Ask Question Facing Programming Problem?
Useful Links
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials


Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright 2007. All rights reserved.