|
-
Feb 2nd, 2002, 11:28 AM
#1
Thread Starter
Randalf the Red
[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.
-
Feb 2nd, 2002, 04:08 PM
#2
Addicted Member
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
-
Feb 2nd, 2002, 10:35 PM
#3
Thread Starter
Randalf the Red
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.
.
-
Feb 4th, 2002, 12:42 PM
#4
Addicted Member
So is doGet() still being called twice?
cudabean
-
Feb 7th, 2002, 12:39 PM
#5
Thread Starter
Randalf the Red
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|