Odd problem with doGet/doPost in same servlet

Discussion in 'Java' started by canoe414@telecom-digest.zzn.com, Nov 12, 2007.

  1. Guest

    Greetings all,

    I've crafted a servlet named insert_stuff with both doGet and doPost
    methods like so:


    doGet( .....) {
    ......................build webpage containing a form named
    insert_stuff
    }

    doPost(....) {
    ....................standard read-form-insert-fields-into-database code
    ....................doGet( request, response);
    }

    The first time the user goes to the webpage .../insert_stuff ie.
    with no parameter doGet is executed and the page with the form is
    built and displayed. Good so far.

    Filling the form and clicking Submit causes doPost to be executed, the
    data does get inserted into the database BUT the page and empty form
    do not get rebuilt and displayed, as if the doGet called from within
    doPost is commented out.

    To further muddy the waters, the servlet works perfectly when the form-
    handling code is commented out, as in an empty form in a newly-built
    page is displayed .

    Any ideas/suggestions/pointers to code snippets are all appreciated.

    TIA,

    Steve
    , Nov 12, 2007
    #1
    1. Advertising

  2. Guest

    The problem turned out to be a statement left over from modifying the
    database code from a query to an add/change/delete

    > doPost(....) {
    > ...................standard read-form-insert-fields-into-database code
    > ...................rs.close(); /*remove this line and all works fine */
    > ...................doGet( request, response);
    >
    > }


    Works like a charm now!

    Thanks anyway,

    Steve
    , Nov 13, 2007
    #2
    1. Advertising

  3. On Nov 13, 10:10 pm, wrote:
    > The problem turned out to be a statement left over from modifying the
    > database code from a query to an add/change/delete
    >
    > > doPost(....) {
    > > ...................standard read-form-insert-fields-into-database code
    > > ...................rs.close(); /*remove this line and all works fine */
    > > ...................doGet( request, response);

    >
    > > }

    >
    > Works like a charm now!


    I'm glad you sorted it out, but based on the information
    you previously posted, how did you expect anyone to know
    the answer in the first place?

    This post even includes some code (apparently the
    offending piece), that wasn't in your original post.

    :)

    --
    Chris
    Chris ( Val ), Nov 13, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fred
    Replies:
    2
    Views:
    4,341
  2. bigbinc

    Fill doGet, doPost in servlet

    bigbinc, Feb 26, 2004, in forum: Java
    Replies:
    1
    Views:
    5,592
    Oscar kind
    Feb 26, 2004
  3. Ryan Gaffuri
    Replies:
    4
    Views:
    3,893
    Sudsy
    Sep 30, 2004
  4. Jeff Kish

    doget dopost handler

    Jeff Kish, Feb 13, 2007, in forum: Java
    Replies:
    0
    Views:
    322
    Jeff Kish
    Feb 13, 2007
  5. =?utf-8?B?6L65IOaxnw==?=

    [Servlet] how to send a stream to servlet doPost

    =?utf-8?B?6L65IOaxnw==?=, Sep 14, 2007, in forum: Java
    Replies:
    3
    Views:
    630
    GArlington
    Sep 14, 2007
Loading...

Share This Page