How to stop Tomcat supplying HTML for statues

2005-09-06 Thread David Goodenough
I have a server which is being used only for XML servlets.  I would like
to send back error responses either as an XML error or, in the case of
a non-200 status code just to send back the status code and a single
line text message.

I set the status (which seems to work) and the text, which again
seems to be sent back on the response header, but I also get a 
bunch of HTML text which gets in the way of processing the
error text which I want to do using XmlHttpRequest.

I have not included any ErrorPage tags in my web.xml nor are there
any in the global web.xml.

I am running Tomcat 5.5

Thanks in advance

David

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to stop Tomcat supplying HTML for statues

2005-09-06 Thread Tim Funk

http://jakarta.apache.org/tomcat/faq/misc.html#error

-Tim

David Goodenough wrote:


I have a server which is being used only for XML servlets.  I would like
to send back error responses either as an XML error or, in the case of
a non-200 status code just to send back the status code and a single
line text message.

I set the status (which seems to work) and the text, which again
seems to be sent back on the response header, but I also get a 
bunch of HTML text which gets in the way of processing the

error text which I want to do using XmlHttpRequest.

I have not included any ErrorPage tags in my web.xml nor are there
any in the global web.xml.
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to stop Tomcat supplying HTML for statues

2005-09-06 Thread David Goodenough
No, this is the reverse of what I want.  I want to STOP it sending an
HTML page, rather than the error-page tag to set it.

David

On Tuesday 06 September 2005 15:06, Tim Funk wrote:
 http://jakarta.apache.org/tomcat/faq/misc.html#error

 -Tim

 David Goodenough wrote:
  I have a server which is being used only for XML servlets.  I would like
  to send back error responses either as an XML error or, in the case of
  a non-200 status code just to send back the status code and a single
  line text message.
 
  I set the status (which seems to work) and the text, which again
  seems to be sent back on the response header, but I also get a
  bunch of HTML text which gets in the way of processing the
  error text which I want to do using XmlHttpRequest.
 
  I have not included any ErrorPage tags in my web.xml nor are there
  any in the global web.xml.

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to stop Tomcat supplying HTML for statues

2005-09-06 Thread Tim Funk

Then make the error page a jsp which clears the stream and prints what you want.

If your servlet already prints what you need, then force the buffer to be 
flushed so that the response is committed and an error page is not shown.


-Tim

David Goodenough wrote:


No, this is the reverse of what I want.  I want to STOP it sending an
HTML page, rather than the error-page tag to set it.

David

On Tuesday 06 September 2005 15:06, Tim Funk wrote:


http://jakarta.apache.org/tomcat/faq/misc.html#error

-Tim

David Goodenough wrote:


I have a server which is being used only for XML servlets.  I would like
to send back error responses either as an XML error or, in the case of
a non-200 status code just to send back the status code and a single
line text message.

I set the status (which seems to work) and the text, which again
seems to be sent back on the response header, but I also get a
bunch of HTML text which gets in the way of processing the
error text which I want to do using XmlHttpRequest.

I have not included any ErrorPage tags in my web.xml nor are there
any in the global web.xml.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to stop Tomcat supplying HTML for statues

2005-09-06 Thread David Goodenough
Maybe we are talking at cross purposes.  I will try to explain what I am 
trying to achieve.

When I have a non-200 response ALL I want to send back is the status
code and the message inserted with the sendError.  Nothing else.

Currently I just do a sendError, should I also write a zero length buffer
to the OutputStream and flush it?

David

On Tuesday 06 September 2005 18:55, Tim Funk wrote:
 Then make the error page a jsp which clears the stream and prints what you
 want.

 If your servlet already prints what you need, then force the buffer to be
 flushed so that the response is committed and an error page is not shown.

 -Tim

 David Goodenough wrote:
  No, this is the reverse of what I want.  I want to STOP it sending an
  HTML page, rather than the error-page tag to set it.
 
  David
 
  On Tuesday 06 September 2005 15:06, Tim Funk wrote:
 http://jakarta.apache.org/tomcat/faq/misc.html#error
 
 -Tim
 
 David Goodenough wrote:
 I have a server which is being used only for XML servlets.  I would like
 to send back error responses either as an XML error or, in the case of
 a non-200 status code just to send back the status code and a single
 line text message.
 
 I set the status (which seems to work) and the text, which again
 seems to be sent back on the response header, but I also get a
 bunch of HTML text which gets in the way of processing the
 error text which I want to do using XmlHttpRequest.
 
 I have not included any ErrorPage tags in my web.xml nor are there
 any in the global web.xml.

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to stop Tomcat supplying HTML for statues

2005-09-06 Thread Tim Funk

Don't use sendError.
- Call response.setStatus(int).
- Calculate the  size of your body text
- Call setContentLength(value from previous step)
- Send the message in the output stream
- Profit! ;)


-Tim

David Goodenough wrote:
Maybe we are talking at cross purposes.  I will try to explain what I am 
trying to achieve.


When I have a non-200 response ALL I want to send back is the status
code and the message inserted with the sendError.  Nothing else.

Currently I just do a sendError, should I also write a zero length buffer
to the OutputStream and flush it?


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]