>>> "Anthony W. Marino" <[EMAIL PROTECTED]> 06-May-01 5:41:00 PM
>>>

>The following request url (as well as all other valid
>urls) always returns null for contentType:
>   http://localhost:8080/xyz/servlet/ViewResource/index.html

I presume you have the servlet bound to /servlet within the context
/xyz


>    // Get the resource to view
>    URL url = null;
>    try
>   {
>      url = getServletContext().getResource(req.getPathInfo());
>    }
>
>Any suggestions?

Most servlet engines do not provide implementations of
URLStreamHandler for the URLs they return... they simply return a
stream handler for FileURLConnection, or JarURLConnection.

If you look at a normal implementation of FileURLConnection it
doesn't have a method for getting the content type... only an
implementation of getInputStream()

This is poor I agree.

My own engine (GNU-Paperclips) implements it's own URLStreamHandlers
for this very reason.

Another problem with non-specialized URLStreamHandlers is the poor
WAR file handling, that's why most engines require that the WAR be
unpacked before use.


There is a way round this. You can implement your own
URLStreamHandler for the file: protocol and specify it when you start
the engine (with a system property). If you want to know how to do
that ask me privately.


Nic Ferrier

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to