I think you will have to examine the first line of the HTTP request header, most likely by accessing the raw input stream via ServletRequest.getInputStream.readLine(). The HTTP request verb will be the first word of the first line.
This is an academic exercise, right? I mean, HttpServlet.service() already separates the GET and POST verbs for you, so I can't think of any other reason to re-invent that wheel.
Philip Shanks, SCJP - Castro Valley, CA
My boss never outsources or has lay-offs, and He's always hiring. I work for Jesus! Prepare your resume!
"Montano MK", thanks for trying to comply with the naming convention, but you're not quite there yet. Your display name must be a first and a last name separated by a space character. Initials for a last name are not acceptable.
Joined: Oct 15, 2002
Originally posted by Bear Bibeault:
Not correct. The request API provides the needed method.
Ah, yes. You are right... HttpRequest.getMethod(). Thank you.
But still, if one is overriding service(), they would only have the object as a ServletRequest, with no HTTP methods. They would have to cast it *up* to HttpServletRequest, and this is where the academic approach falters.
To make this a more interesting exercise, one could implement their own HttpServlet class extending javax.servlet.GenericServlet and try implementing the service method there. Then they would be back to examining the HTTP request header in its native state. From the original message, this is what it seemed like Montano was attempting. [ February 07, 2007: Message edited by: Philip Shanks ]