Results 1 to 5 of 5

Thread: [Resolved] doGet() being called twice??

  1. #1

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    [Resolved] doGet() being called twice??

    I wrote a servlet that reads an HTML file, parses the contents, replaces certain delimited strings with some other values, and after that flushes the processed output to the client.

    I find that in this servlet the doGet() method executes twice, although I am calling the servlet only once, through the browser.

    .
    Last edited by honeybee; Feb 7th, 2002 at 12:40 PM.
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  2. #2
    Addicted Member
    Join Date
    Nov 2001
    Location
    Yewston, Texis
    Posts
    240
    Here's a theory:

    Do you also declare a doPost something like this?

    Code:
    
      /**
       * Linked to doGet so GET and POST are handled the same way
       */
      public void doPost(HttpServletRequest req, HttpServletResponse resp) {
        doGet(req, resp);
      }
    
    For this to occur, your html would invoke the servlet with POST, plus you throw in some GET arguments as well like: /servlet?x=7&y=3, then in your servlet, both the doPost and the doGet fire because each has something unique to process. The thing is, the doPost is directed to execute the doGet. Voila! Two doGets.

    cudabean

  3. #3

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    I had a doPost() method declared which simply called doGet(). After I noticed that doGet() was being called twice, I commented out the doPost() method.

    And the servlet is invoked by calling it directly in the URL itself, the parameters are passed in the URL string itself.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  4. #4
    Addicted Member
    Join Date
    Nov 2001
    Location
    Yewston, Texis
    Posts
    240
    So is doGet() still being called twice?

    cudabean

  5. #5

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    Yep, I think that was the culprit. I commented out the doPost method and it worked.

    Thanks for the help

    However, I fail to understand how the doGet() and doPost() both are called, when I invoke the servlet by directly typing its URL in the address bar.

    .
    Last edited by honeybee; Feb 7th, 2002 at 12:42 PM.
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width