HTML code to servlet to database using jdbc

Ads

 
 

Share on Google+Share on Google+

anjali pathuri
HTML code to servlet to database using jdbc
1 Answer(s)      6 years and 10 months ago
Posted in : HTML

pls send me the code related to the title

Ads
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


Ads









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: 1)form.html...=req.getParameter("msg"); res.setContentType("text/html"); PrintWriter
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: Insert data into database Thanks
Advertisements
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: <html> <...Sending form data from HTML page to SQLserver 2005 database by calling servlet
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
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
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. 
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
JDBC Connection code to connect servlet with oracle.
JDBC Connection code to connect servlet with oracle.  JDBC Connection code to connect servlet with oracle
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
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 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
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
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
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
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
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
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
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
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
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
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
how to display a table from database using servlet
how to display a table from database using servlet  how to display... the following link: http://roseindia.net/jsp/servlet-jsp-data-list.shtml Thanks...://roseindia.net/jsp/servlet-jsp-data-list.shtml Thanks
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: 1)form.html: <html> <...("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc
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 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
Connecting to the Database Using JDBC and Pure Java driver
engine our application communicate with database using JDBC...Connecting to the Database JDBC Driver In our search engine we are using MySQL database server and MM.MySQL Driver
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
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

Ads

 
Advertisement null

Ads