----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files.  Don't make us guess your problem!!!
----------------------------------------------------------------

Hi Fernando,

Thank you for your reply. Indeed it makes sense; I subsequently tried a
POST and found the ContentType set as expected.

Two things contributed to my initial confusion:

1) I was working thro the O'Reilly Java Servlet Programming book and on
page 33 there is a simple example which within the doGet performs a
getContentType. The example essentially reads from the request buffered
reader to retrieve the document referenced by the supplied URL and so
filter the contents prior to return to the client. In other words there
seems to be a direct handle on the target file which allows reading via
the request object buffered reader. Certainly this does not seem to be
the case when using Apache. (I think they use the Java Web Server.)

2) The AddHandler directive should invoke my handler if the target of
the URL does indeed exist and is of the appropriate type. In other words
various apache modules will have run such that by the time my content
handler is invoked Apache knows what the content type is. I suppose what
I really was after was NOT to retrieve the content type from the request
object itself but rather the content type as known by Apache and
probably accessible via some call to the Apache API. 

Kind regards,

Simon

Fernando Salazar wrote:
> 
> ----------------------------------------------------------------
> BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
> WHEN YOU POST, include all relevant version numbers, log files,
> and configuration files.  Don't make us guess your problem!!!
> ----------------------------------------------------------------
> 
> >
> >I am trying to set up a simple content handler and have the following in
> >the .htaccess file in the appropriate directory:
> >
> >Action MyContent /servlets/Mycontent
> >AddHandler MyContent html
> >
> >What puzzles me is that within the servlet doGet (or doPost) the call to
> >the request object getContentType method always returns NULL. Assuming
> >the target of the URL exists and has the .html extension should not this
> >call return a non NULL value?
> >
> >Any hints/ideas?
> 
> request.getContentType() returns the content-type of data that
> *accompanies* the request from the client;
> eg, in the case of a POST, it is most likely application/x-www-form-urlencoded.
> 
> In your case, there is no data that accompanies the request, the request
> contains only a URI that it
> is up to your handler to process and return.
> 
> - Fernando
> 
> =======================================
> Fernando Salazar <[EMAIL PROTECTED]>
> w -781-392-2514
> 
> --
> --------------------------------------------------------------
> Please read the FAQ! <http://java.apache.org/faq/>
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Archives and Other:  <http://java.apache.org/main/mail.html>
> Problems?:           [EMAIL PROTECTED]

-- 
Simon Heaton
Principal Technical Consultant
Software AG UK Ltd.


--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to