• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

LogServlet revisited

 
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
whippersnapper
Posts: 1843
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:


overwritten


But I meant "overidden," of course.
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The doGet() method of LogServlet is basically used for debugging servlets (in the real world).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic