i'm making a web application based on jsp
i wan't a code that when a button clicked, take value from textbox and insert its value into mysql database pool maybe the sql stmt only isn't right
my code is:
<form id="form1" name="form1" method="post" action="http://localhost:8080/servlet/mailservlet">
<p> </p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="88%"> <textarea name="txtarea_Post_Wall" id="txtarea_Post_Wall" cols="45" rows="2"></textarea></td>
<td width="12%"><strong>
<input type="submit" name="btn_Post_Wall" id="btn_Post_Wall" value="Post" />
<%
Connection con = null;
Statement stmt = null;
try {
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/DataSource");
System.out.println("Got DataSource: " +ds.toString() );
con = ds.getConnection();
System.out.println("Got Connection: " +con.toString() +"\n");
} catch(java.lang.Exception e) {
e.printStackTrace();
System.err.print(e.getClass().getName());
System.err.println(e.getMessage());
}
try {
stmt = con.createStatement();
String tet=(String) session.getAttribute("txtarea_Post_Wall2");
ResultSet rs = stmt.executeQuery("INSERT INTO wall (text, ID, author) VALUES ('" + tet + "' , 1 , dfdf)");
System.out.println("inserted");
rs.close();
stmt.close();
con.close();
}
catch(java.lang.Exception e) {
e.printStackTrace();
System.err.print(e.getClass().getName());
System.err.println(e.getMessage());
}
%>
</strong></td>
</tr>
<tr>
<td> Max. 1000 Characters </td>
<td> </td>
</tr>
<tr>
<td height="21"> </td>
<td> </td>
</tr>
</table>
<p> </p>
</form></td>
plz answer me