Stephen,

It looks like you've overriden the doGet(), but if you're POST-ing, then
you'll have to define the doPost() method.
Try the following:

[...blah, blah, blah]

public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    this.doGet(request, response);
}
[...blah, blah, blah]


Hope this helps,
-Duck Jin


----- Original Message -----
From: Lambert, Stephen : CO IR <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 24, 2000 1:23 PM
Subject: SERVLET - inserting databse values from an HTML form.


> I  have a working servlet that can query my Oracle database and display
the
> results to an HTML page(Hooray!).
>
> The second phase of this servlet is to insert data into the Oracle
database
> from an HTML form using the POST METHOD.
> The HTML FORM names are:(theQ1, theQ2, theComment1, thecomment2, fname,
> lname).
>
> Can someone please correct my java/sql syntax or point me to an actual
> working sample code that shows how to insert HTML data into an Oracle
> database.
>
>
> My servlet "JdbcServlet3" is listed below and will compile without errors.
> However, when I try to POST the HTML FORM, I recieve the following error:
> Bad Request
> Your browser sent a request that this server could not understand.
>
>
>
****************************************************************************
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.sql.*;
>
> /**
>  * JdbcServlet writes Legacy's Web Survey information to a JDBC database
>  * from a HTML form.
>  *
>  * @author Stephen B. Lambert
>  * @version 0.1a, 02/21/2000
>  */
> public class JdbcServlet3 extends HttpServlet
>      implements SingleThreadModel {
>
>
>   private Connection conn;
> private void dbConnect() throws SQLException {
>
>
>
>    DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
>    conn = DriverManager.getConnection
> ("jdbc:oracle:thin:@w121c20.legacyhs:1521:FIRST",
>                                        "slambert", "password");
> }
>
>   /**
>    * doGet method is called in response to a GET request
>    */
> public void doGet(HttpServletRequest request,
>   HttpServletResponse response) throws ServletException,
>   IOException
> {
>       PrintWriter out = response.getWriter();
>     try
>
>     {
>       response.setContentType("text/html"); file://returns HTML
>
>       file://get handle to output stream
> //      PrintWriter out = response.getWriter();
>
>       file://create statement
>      dbConnect();
>       PreparedStatement stat = conn.prepareStatement( "INSERT INTO
> LHS_WEB_Survey Q1, Q2, DO_BEST, NEEDS_IMPROVE, F_NAME, L_NAME FROM " +
>         "LHS_WEB_Survey" +
>        "VALUES ( theQ1, theQ2, theQ3, theComment1, theComment2, fname,
> lname");
>
>
>       file://query database for result set
>       ResultSet survey = stat.executeQuery();
>       file://generate HTML document to return to client
>       out.println("<HTML>");
>       out.println("<HEAD><TITLE>Survey List</TITLE></HEAD>");
>       out.println("<BODY>");
>       out.println("<H2>Survey List</H2>");
>       out.println("<TABLE BORDER=1>"); file://create an HTML table
>       out.println("<TH>Satisfaction</TH>");
>       out.println("<TH>Parking</TH>");
>       out.println("<TH>Did Best?</TH>");
>       out.println("<TH>Needed Improvement</TH>");
>       out.println("<TH>First Name</TH>");
>       out.println("<TH>Last Name</TH></TR>");
>
>       while (survey.next()) file://iterate through all records
>       {
>         file://add a table row for each record
>         out.println("<TR><TD>" +
>           survey.getString("q1")+ "</TD><TD>" +
>           survey.getString("q2") + "</TD><TD>" +
>           survey.getString("DO_BEST") + "</TD><TD>" +
>           survey.getString("NEEDS_IMPROVE") + "</TD><TD>" +
>           survey.getString("F_NAME") + "</TD><TD>" +
>           survey.getString("L_NAME") + "</TD></TR>");
>       }
>
>       out.println("</TABLE>");
>       out.println("</BODY></HTML>");
>     }
>     catch (Exception e)
>     {
>         out.println(e.toString());
>
>     }
>     out.close();
>   }
>
>   /**
>    * Tells the server about this servlet
>    */
>   public String getServletInfo()
>   {
>     return "Sample JDBC servlet";
>   }
> }
>
>
>
***************************************************************************
> Thank you!
> Stephen.
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to