HTML code to servlet to database using jdbc

HTML code to servlet to database using jdbc

pls send me the code related to the title

View Answers

December 6, 2010 at 12:49 PM

Hi Friend,

Try the following code:

1)form.html:

<html>
<form method="post" action="http://localhost:8080/examples/Data">
<table>
<tr><td>Message:</td><td><input type="text" name="msg"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>

2)Data.java:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;

public class Data extends HttpServlet { 
    public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException {
        String msg=req.getParameter("msg");
        res.setContentType("text/html");
        PrintWriter out = res.getWriter();
        System.out.println(msg);
        try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:student","","");
    Statement stmt=con.createStatement();
    int i=stmt.executeUpdate("insert into data(message) values('"+msg+"')");
    out.println("Message successfully added!");
        con.close();
        } 
        catch(Exception e){
        System.out.println(e);
        }
        }
        }

Thanks









Related Tutorials/Questions & Answers:
HTML code to servlet to database using jdbc
HTML code to servlet to database using jdbc  pls send me the code related to the title   Hi Friend, Try the following code:ADS... { String msg=req.getParameter("msg"); res.setContentType("text/html
Sending form data from HTML page to SQLserver 2005 database by calling servlet code
from html page to database by calling servlet code from html page .   Hello Friend, Try the following code: 1)callServlet.html:ADS_TO_REPLACE_1 <...Sending form data from HTML page to SQLserver 2005 database by calling servlet
Advertisements
database entry using jdbc
database entry using jdbc  Give me a program to enter records in table using jdbc in java.   Hi Friend, Please visit the following link:ADS_TO_REPLACE_1 Insert data into database Thanks
how to retrieve text and images from mysql database and show on html page using jsp servlet
how to retrieve text and images from mysql database and show on html page using jsp servlet  <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> Insert title here h3
html dropdownlist code - JSP-Servlet
html dropdownlist code  hi how to get textfield in html when i select the option others in the dropdown list, pls provide the code?   Hi Friend, Try the following code: function show(){ var op
Html/JavaScript code - JSP-Servlet
Html/JavaScript code  I have 2 JSPs JSP1 and JSP2. 1.in JSP1 i have a table being displayed using the tag and cells in it contain links(huge..., ------------------------------------------ If, you have any problem then , please send me detail with code. Thanks. 
inserting multiple file formats into database using html
inserting multiple file formats into database using html   hi the code was working fine,i want to choose the file and then upload to database,by using html.whether it is possible to upload larger file size,please explain
JDBC Connection code to connect servlet with oracle.
JDBC Connection code to connect servlet with oracle.  JDBC Connection code to connect servlet with oracle
How to delete the row from the Database by using servlet
: Delete row from database using servlet   In that link solution... details (HTML Page, Database table, Servlet Program) see this link link text...How to delete the row from the Database by using servlet  Dear Sir
download code using servlet - Servlet Interview Questions
download code using servlet  How to download a file from web to our system using Servlet
database connectivity using jsp code
database connectivity using jsp code  i have two tables employee and adduser insert into adduser(Emp_Id,Ename,Designation,Password,ReTypePassword...),'bbbb','bbbb'); so this syntax is possible to use in jsp code based
JSP,JDBC and HTML(Very Urgent) - JSP-Servlet
details from database using JDBC and JSP. The home page i.e HTML Page must contain... the code: I am not using any html. I used only jsp & jdbc. HOme Page...JSP,JDBC and HTML(Very Urgent)  Respected Sir/Madam, Thanks
how to insert data in database using html+jsp
how to insert data in database using html+jsp  anyone know what is wrong with my code? print("<% /* Create string... and database name. Here machine name id localhost and database name
code to establish jdbc database connectivity in jsp
code to establish jdbc database connectivity in jsp  Dear sir, i'm in need of code and procedure to establish jdbc connectivity in jsp
code to establish jdbc database connectivity in jsp
code to establish jdbc database connectivity in jsp  Dear sir, i'm in need of code and procedure to establish jdbc connectivity in jsp
edit database using jsp and servlet
edit database using jsp and servlet  I am creating a website using jsp and servlets that is used to view houses from a database. I want to be able... information from the database in the textboxes. Please help me to display
Insert Image into Database Using Servlet
Insert  Image into Database Using Servlet   ... image into database table using Servlet. This type of program is useful in social... the image from database using Servlet. After retrieving the image from database
Insert  Image into Database Using Servlet
Insert  Image into Database Using Servlet   ... of inserting image into database table using Servlet. This type of program is useful... to retrieve the image from database using Servlet. After retrieving the image from
View source code of a html page using java ..
View source code of a html page using java ..  I could find the html source code of a web page using the following program, http://download.oracle.com/javase/1.4.2/docs/api/java/net/URLConnection.html i could get the html code
regarding ms acces database and servlet - JDBC
name (e.g emp) 6. Click "Ok" and then try the following Servlet code where...regarding ms acces database and servlet  hello there, i am trying... database, i could run java main programs(i e not servlets public static void main
unable to retrive the data from mysql using servlet using jdbc driver
unable to retrive the data from mysql using servlet using jdbc driver  Hi, i have a servlet program..to verify the login and redirect to correct html page on verification. public class LoginServlet extends HttpServlet implements
to run html code in web browser - JSP-Servlet
to run html code in web browser  how to run jsp file which calls html file on web browser??  Hi Friend, Try the following code: 1)form.jsp: Enter Name: 2)welcome.html: Add Profile Edit
how to display a table from database using servlet
how to display a table from database using servlet  how to display... the following link:ADS_TO_REPLACE_1 http://roseindia.net/jsp/servlet-jsp-data... the following link: http://roseindia.net/jsp/servlet-jsp-data-list.shtml ThanksADS
How to display image in jsp from database using Servlet?
How to display image in jsp from database using Servlet?  Hi, How to display image in jsp from database using Servlet? Thanks   Hi, You will find code and example program at Retrieve image from database using Servlet
jsp or sevlet and html form to send picture to database - JSP-Servlet
that contains his picture to database. What I need are html page for the form that will browse for the picture, jsp or servlet that the info from html will go...jsp or sevlet and html form to send picture to database  Hello guys
code for password strength using jsp-servlet
code for password strength using jsp-servlet  hi.............. plz help me to give code for password strength using jsp-servlet for implementation in my project as soon as possible because i want to show this functionality in my
How to retrieve image from database using jsp and servlet?
How to retrieve image from database using jsp and servlet?  Hi, I am trying to find code for displaying the image from database in a JSP page. How to retrieve image from database using jsp and servlet
Jsp Code to store date in database - JSP-Servlet
Jsp Code to store date in database   Hi, Can u give me jsp code to store current date in to database. Thanks Prakash
Image upload in mysql database using jsp servlet
Image upload in mysql database using jsp servlet  Hello, I need code to insert image in mysql database, I have seen the code which is already in your portal but it is not inserting image into database it save in the folder
Upload Excel into Database Table Using SERVLET - JSP-Servlet
Upload Excel into Database Table Using SERVLET  Hi i hava sitution that upload .xls file into database table which has same coloumn names... in database table are NAME,ID,SAL. please help me to upload that excel using
coding for horizontal menubar using using html or javascript - JSP-Servlet
coding for horizontal menubar using using html or javascript  hii friends, i wanted to implement horizontal menubar in my project tht wil open the links to diffrnt pages kindly help
how to load values of html form into an excel table using java servlet?
how to load values of html form into an excel table using java servlet?   i have written a java servlet program, which has a html form to be filled. after filling the form the servlet generates a receipt and the values should
Populate dropdown menu from database using jsp and servlet
Populate dropdown menu from database using jsp and servlet  please i need code to populate dropdown menu from mysql database using jsp and servlet. thanks
fetch and insert multiple rows into mysql database using jsp servlet
a problem to insert multiple rows into database using a single insert query here is the code of both jsp and servlet <%@page contentType="text/html...fetch and insert multiple rows into mysql database using jsp servlet  
Database connectivity with jsp code - JSP-Servlet
Database connectivity with jsp code  I have written a program in java having connectivity with online_exam. Its working properly. Connection has been established and the code in java is showing the output. But the problem
storing date from html form to oracle 10g using servlet
storing date from html form to oracle 10g using servlet  i have... this date month year from html form into oracle 10g database where i have... necessary coding..not mentioned here my full html form and servlet coding
How to populate an HTML table using jstl code - Spring
How to populate an HTML table using jstl code  Hi I want to populate an HTML table using jstl code.I am using Hasp map.For 1 column its okay it works fine.But if I am suppose to populate 2 or 3 columns from the database than
database backup and restore using java - JDBC
database backup and restore using java  Hi... I have MS Access 2000 database.I want to backup and restore the db using jdbc.What's the procedure for that. Thanks in advance
code for jsp to db connection using jdbc
code for jsp to db connection using jdbc  please send me the code   Hi Friend, Try the following code:ADS_TO_REPLACE_1 1)form.html: <... = DriverManager.getConnection("jdbc:odbc:student"); Statement st=con.createStatement
Upadate Database using updatable fields - JSP-Servlet
Upadate Database using updatable fields  Hi, Thanks for previous... is pulled from database and displayed in the updatable fields.Means after user submits, the database table should get updated with these new entries he has made
give me source code of webpage creation using html
give me source code of webpage creation using html  how to create a webpage using html
fetch record from oracle database using jsp-servlet?
fetch record from oracle database using jsp-servlet?  how can i fetch data from oracle database by using jsp-servlet. i'm using eclipse, tomcat server and oracle database and creating jsp pages and also using servlet
storing date from html form to oracle 10g using servlet
storing date from html form to oracle 10g using servlet  i have... this date month year from html form into oracle 10g database where i have... necessary coding..not mentioned here my full html form and servlet coding
How to delete the row from the Database by using while loop in servlet
server database by using Servlet program (Tomcat server). In Database table... Servlet (JDBC). you entered 'ramanujan' is 9 character but in the database...How to delete the row from the Database by using while loop in servlet 
How to browse excel file and stored the contents into the database using jsp/servlet?
How to browse excel file and stored the contents into the database using jsp/servlet?  Hi.. I want to browse excel file and stored the file data into the My-sql database using jsp/servlet
How to retrive database information using servlet and disply in table format in browser
How to retrive database information using servlet and disply in table format in browser  Hi, any one send code how to retrive the data base information in table format in web browser
How to pass and catch HTML parameters to a Java program using REST services?(without using servlet/jsp)
How to pass and catch HTML parameters to a Java program using REST services?(without using servlet/jsp)  Hello, I am new to these technologies i.e.... and catch HTML parameters to a Java program using REST services?(without using
How to Open Picture From M.S. Access Database using Java Servlet ?
How to Open Picture From M.S. Access Database using Java Servlet ?  ... Database But i m still not able to open this picture through Java using M.S. Access and i wants to open this Picture On Web Browser using Java Servlet anybody can
mini project using html,javascript and ms access with source code
mini project using html,javascript and ms access with source code  I want a mini project which uses html and java script and backend as ms access with source code. plz send its important and urgent
Connecting to the Database Using JDBC and Pure Java driver
Connecting to the Database JDBC Driver In our search engine we are using MySQL database server and MM.MySQL Driver.... In this search engine our application communicate with database using

Ads