Arrrgh -- absolutely correct.
Moral of the story: /Think/ about what your tool (Eclipse) automatically fills in for you before you start adding code!

Thanks much.

On Feb 10, 2010, at 4:06 PM, Christopher Schultz wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ken,

On 2/10/2010 3:20 PM, Ken Bowen wrote:
I feel silly, but...

protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
   super.doGet(req, resp);

Heh, that /is/ silly.

The javadoc for HttpServlet states that, by implementing doGet, you
enable the GET method for your servlet. By calling the superclass's
doGet method, you get the default implementation, which is to /not/
support GET (sorry, I can't find the source for HttpServlet quite yet,
so you'll have to read bytecode):

protected void doGet(javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse)   throws
javax.servlet.ServletException, java.io.IOException;
 Code:
  0:   aload_1
  1:   invokeinterface #7,  1; //InterfaceMethod
javax/servlet/http/HttpServletRequest.getProtocol:()Ljava/lang/String;
  6:   astore_3
  7:   getstatic       #8; //Field lStrings:Ljava/util/ResourceBundle;
  10:  ldc     #9; //String http.method_get_not_supported
  12:  invokevirtual   #10; //Method
java/util/ResourceBundle.getString:(Ljava/lang/String;)Ljava/lang/ String;
  15:  astore  4
  17:  aload_3
  18:  ldc     #11; //String 1.1
  20:  invokevirtual   #12; //Method
java/lang/String.endsWith:(Ljava/lang/String;)Z
  23:  ifeq    40
  26:  aload_2
  27:  sipush  405
  30:  aload   4
  32:  invokeinterface #13,  3; //InterfaceMethod
javax/servlet/http/HttpServletResponse.sendError:(ILjava/lang/ String;)V
  37:  goto    51
  40:  aload_2
  41:  sipush  400
  44:  aload   4
  46:  invokeinterface #13,  3; //InterfaceMethod
javax/servlet/http/HttpServletResponse.sendError:(ILjava/lang/ String;)V
  51:  return

But what is strange is that in catalina.out, I get:

SBTester.doGet: query=foo=bar

Your servlet is still running, but the response has already been sent to
the client saying "405 Unsupported Protocol".

I'm actually a little surprised that you didn't get a response already
committed" error or something like that when you tried to write to the
output stream.

Try removing the call to super.doGet().

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAktzH7kACgkQ9CaO5/Lv0PCHAwCfSlabLDHBEkHYBcay+2IVjJcm
k0QAmgMBcazdRFf42yIHZgjs1j3aH8u5
=RPqh
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to