Hi Jim,
Ok, I made the swap in both *Router servlets. Please check to make sure they
work ok for you now.
Thanks,
-Matt
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Jim Hazen
> Sent: Sunday, May 27, 2001 3:30 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Bug in RPCRouterServlet doGet() in SOAP 2.2 rc3
>
>
> Thanks Glen,
>
> This is a problem for me, and I'm sure many other people. Using
> HTTP GET is
> generally a corner case, and as such, people probably don't have
> this problem
> much. However it's documented all over the Servlet JavaDoc's
> that you *must* do
> all setting of the ServletResponse properties before calling
> getWriter(). They
> even site this example by name. I've quoted from the Sun Servlet
> API 2.2 below:
>
> http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/Ser
> vletResponse.html#getWriter()
>
> getWriter
> public java.io.PrintWriter getWriter()
> throws java.io.IOException
>
> Returns a PrintWriter object that can send character text to the
> client. The
> character encoding used is the one specified in the charset=
> property of the
> setContentType(java.lang.String) method, which must be called
> before calling
> this method for the charset to take effect.
>
> If necessary, the MIME type of the response is modified to
> reflect the character
> encoding used.
>
> Either this method or getOutputStream() may be called to write
> the body, not
> both.
>
> And setContentType()
>
> http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/Ser
> vletResponse.html#setContentType(java.lang.String)
>
>
>
> public void setContentType(java.lang.String type)
>
> Sets the content type of the response being sent to the client.
> The content type
> may include the type of character encoding used, for example, text/html;
> charset=ISO-8859-4.
>
> If obtaining a PrintWriter, this method should be called first.
>
> Of course all Servlet containers are implemented differently and
> your mileage
> may vary. I get exceptions under Weblogic 4.5.1. Under Tomcat
> things might be
> different, hey it might even work.
>
> Maybe there were other changes between 2.1 and 2.2 that caused
> this problem to
> show up. Maybe somewhere else in the code things were
> initialized to have a
> content type of text/xml and it's the change to text/html that freaks out
> Weblogic. I'm not really sure, and it doesn't really matter.
> The fix to this
> problem doesn't take much research. I've tested this, swap the
> two lines and
> everything works. This even makes sense logically. You should have to
> configure the context that is giving you your Writer before you
> get it. And
> once gotten shouldn't be able to change things like content type,
> since the
> content type needs to be sent with the HTTP headers and as such,
> after you've
> started to stream data can't be changed.
>
> I think this is a pretty legit and simple request, and don't
> quite understand
> the push back on this.
>
> -Jim
>
> > It looks to me like the setContentType and the slight html changes were
> > added just to make the doGet() code a little cleaner and more
> correct. I
> > have a strong suspicion that adding the setContentType after
> the getWriter
> > was just an oversight. Jim can certainly fix it in his
> version, but IMHO if
> > it causes a problem for anyone, we should fix it.
> >
> > --G
> >
> > ----- Original Message -----
> > From: "Sanjiva Weerawarana" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Friday, May 25, 2001 11:13 PM
> > Subject: Re: Bug in RPCRouterServlet doGet() in SOAP 2.2 rc3
> >
> > > It appears that the setContentType was introduced between
> > > revisions 1.5 and 1.6 of RPCRouterServlet.java:
> > >
> > >
> >
> http://xml.apache.org/websrc/cvsweb.cgi/xml-soap/java/src/org/apac
> he/soap/se
> > > rver/http/RPCRouterServlet.java.diff?r1=1.5&r2=1.6&diff_format=h
> > >
> > > The change was committed October 17th, 2000.
> > >
> > > That means this code was exactly the same in v2.1 too. I am not
> > > inclined to changing it at this point .. without knowing why
> > > it was added. Also, the fact that it was not reported for so
> > > long means that it must work pretty much all the time.
> > >
> > > Conceptually, it seems to me that the change you're suggesting is
> > > correct. However, given the age of that code ..
> > >
> > > Sanjiva.
> > >
> > > ----- Original Message -----
> > > From: "Jim Hazen" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Friday, May 25, 2001 4:38 PM
> > > Subject: Bug in RPCRouterServlet doGet() in SOAP 2.2 rc3
> > >
> > >
> > > > There seems to be a problem in the RPCRouterServlet doGet() method.
> > > >
> > > > Instead of printing the 'GET not supported. Talk to me
> using POST' HTTP
> > > > response. My server (old version of Weblogic) starts throwing
> > > > IllegalStateExceptions:
> > > >
> > > > java.lang.IllegalStateException: Attempt to change ContentType after
> > > calling
> > > > getPrintWriter()
> > > >
> > > > I've looked at the code and sure enough, this is the case.
> > > >
> > > > public void doGet (HttpServletRequest req, HttpServletResponse res)
> > > > throws ServletException, IOException {
> > > > PrintWriter out = res.getWriter ();
> > > >
> > > > res.setContentType("text/html");
> > > >
> > > > ...
> > > >
> > > > If the setContentType and getWriter lines are swapped the
> problem goes
> > > away.
> > > >
> > > > Could someone please make this simple fix before the final release.
> > > >
> > > > Thanks,
> > > > Jim
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, email: [EMAIL PROTECTED]
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, email: [EMAIL PROTECTED]
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, email: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]