DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12771>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12771

[PATCH] IllegalStateException on include of non-mapped mimetype

           Summary: [PATCH] IllegalStateException on include of non-mapped
                    mimetype
           Product: Tomcat 4
           Version: Nightly Build
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Catalina
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


An IllegalState exception is thrown on .include() if the included file has an
extension not mapped to any mime types.

To reproduce: 
- create 2 files foo.jsp and foo.nomimetype
- foo.jsp has 1 line  <jsp:include page="foo.nomimetype"/>
- foo.nomimetype can be any file with "stuff" text prefered
- accessing foo.jsp throws IllegalException error

Temporary Workaround:
Adding a mime-type mapping in web.xml for file extension "nomimetype" alleviates
the problem.

Patch will be attached to fix DefaultServlet. Currently it does this:
----------------------------------------
    try {
        ostream = response.getOutputStream();
    } catch (IllegalStateException e) {
        // If it fails, we try to get a Writer instead if we're
        // trying to serve a text file
        if ( (contentType != null)
             && (contentType.startsWith("text")) ) {
            writer = response.getWriter();
        } else {
            throw e;
        }
    }
----------------------------------------
So if NO mime type is mapped, an exception will be thrown. My patch will change
++++++++++++++++++++++++++++++++++++++++++
        if ( (contentType != null)
             && (contentType.startsWith("text")) ) {
++++++++++++++++++++++++++++++++++++++++++
to
++++++++++++++++++++++++++++++++++++++++++
        if ( (contentType == null)
             || (contentType.startsWith("text")) ) {
++++++++++++++++++++++++++++++++++++++++++

So on not finding a mime-type it will default to obtaining a the Writer. 

This will be helpful for people who use .inc as a text include but don't have it
mapped.

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

Reply via email to