
pls send me the code related to the title

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
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.