Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet

 
shashi bhushan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am struck up in an project how to insert the values from the html to the dopost method of httpservlet. i used all conection to jdbcodbc bridge but not working backend access.
i know it is very simple, helpme na?
a thousand wishes
 
Arvind Karanth
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can you be more specific and let me know the back-end on which you are working. If possible paste ur code on this page so that if there are any logical errors we shall know.
bye
Arvind Karanth
[This message has been edited by Arvind Karanth (edited November 25, 2000).]
 
shashi bhushan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class postResume extends HttpServlet
{
//private ConnectionPool pool;
private Connection con = null;

public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException,
IOException
{
//Connection con=null;

res.setContentType("text/plain");
PrintWriter pw=res.getWriter();
String name=req.getParameter("name");
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc dbc:Resume","","");
//con = pool.getConnection();
con.setAutoCommit(false);
//stmt = con.createStatement();
PreparedStatement pstmt;
pstmt = con.prepareStatement("Insert into postResume (name, email, status) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
pstmt.setString(1,name);
con.commit();
pw.println("Thanks for giving the info, we will get back soon");
}
catch(Exception e)
{
try
{
con.rollback();
}
catch(SQLException ignored){}
pw.println("Submission failed, please contact technical support.");
}
finally
{
try
{
if(con != null) con.close();
}
catch (SQLException ignored){}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic