Picking this up again after looking at JavaRanch Common's LogServlet class a little closer. First, thanks all, for the answers in the first thread (doGet exceptions). Initially it was like the "wierdo" doGets and doPosts just worked, sorta like magic (I'll buy that, but not for long) but the connection between the "normal" doGets and doPosts in LogServlet was not at all clear. It's making sense to me now, I'm hoping I can paraphrase it well enough to get feedback on whether I'm on the right track. As Mike M said, "In the case of a browser post or get being issued to an instance of your servlet, the application server will call the standard API versions of doPost() and doGet(), which in turn will call the weirdo versions that you've overwritten." *click, a light goes on* (A service() gets called before the doPost() or doGet(), right?) The LogServlet's "normal" doGet basically first checks a condition (that our servlets' requests don't fullfill), then goes to it's else block. Here the only thing that happens is the simplified doGet gets called, passing along the CastMap and Printwriter that it prepared for us. And that's it. Can I go out and play now?
Joined: Mar 25, 2001
Go out and play! Sounds to me that you've got this down pat. I'm a little fuzzy on the service() method, so I'll pass on commenting on that. One remark:
The LogServlet's "normal" doGet basically first checks a condition (that our servlets' requests don't fullfill)
Per the assignments, our servlets don't pass the condition you mention. But it's not a big deal to make them if you want to. If the servlet defines doGet(), you can do it programmatically or by how you invoke the servlet in the browser window. I see from the log that you've passed Servlets-1. Run it once the normal way, then run it again by submitting this to your browser: http://localhost/servlet/NowServlet?secretservletkey=Spooooon! Now you can play with some of the features that LogServlet provides. I write:
But I meant "overidden," of course.
Marilyn de Queiroz
Joined: Jul 22, 2000
The doGet() method of LogServlet is basically used for debugging servlets (in the real world).
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt