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



Home Answers Viewqa HTML HTML code to servlet to database using jdbc
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


anjali pathuri
HTML code to servlet to database using jdbc
1 Answer(s)      4 years and a month ago
Posted in : HTML


pls send me the code related to the title


Advertisement
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: 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
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
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
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 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
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
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
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
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
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   ... 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
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
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
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
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
HTML - JDBC
to retrieve tha data into second combo box from Database when ever select option from combobox. please send me code of html   Hi Friend, To do...HTML  I created on html page with two comboboxes. when ever i select
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
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
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
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
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
 

 

 

DMCA.com