You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jeff Kilbride <je...@kilbride.com> on 2001/12/08 03:27:49 UTC
Re: Unable to include *.sum files (Again) -- FOUND! Help please, Craig?
Ok, This is a longer post, so bear with me. I looked through the source and
found that serveResource() in
org.apache.catalina.servlets.DefaultServlet.java is the culprit. Before
serving the included file, serveResource() retrieves the MIME type of the
included file on line 1194 (cvs from today):
----------
String contentType =
getServletContext().getMimeType(resourceInfo.path);
----------
Then, on lines 1230 through 1247, if there's any content in the included
file, it tries to serve it:
----------
if (content) {
// Trying to retrieve the servlet output stream
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;
}
}
}
----------
Since the getOutputStream() method of
org.apache.jasper.runtime.ServletResponseWrapperInclude.java always throws
an IllegalStateException, the try above will always fail and serveResource()
will try to obtain a Writer instead. At that point, if you haven't set up an
applicable MIME type for the file you are trying to include, contentType
will be null and the exception will be thrown. If you *have* set up a MIME
type, but it doesn't start with "text", the exception will also be thrown.
Craig, does this make sense for JSPs? I understand why you would do this for
a servlet, but a JSP never has an output stream available -- so this limits
files included with the jsp:include directive to only those that have
registered MIME types that begin with "text". The obvious solution is to put
<mime-mapping> statements for all your file types into web.xml, but what
happens if you're dynamically generating filenames with extensions like
".001", ".002", ".003", etc... That means you have to add 999 mime-mapping
statements -- if you even know what all the dynamic names will be!
Would it make more sense, for JSP's only, to default the contentType
variable to "text/html"? After all, the web server defaults to "text/html"
for most instances when it can't find an appropriate MIME type. Am I missing
something?
Thanks,
--jeff
----- Original Message -----
From: "Jeff Kilbride" <je...@kilbride.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Friday, December 07, 2001 4:41 PM
Subject: Re: Unable to include *.sum files (Again)
> If it does, then it's violating the spec. The spec doesn't specify any
> extensions that can or cannot be included. It just says it has to be a
> String that is a relative URL. The string "./myText.foo" satisfies that
and
> the file myText.foo pulls up correctly in my browser with the following
> content:
>
> "This is the myText.foo file!"
>
> However, when you include the myText.foo file using the jsp:include
> directive, you get an exception. I think that's a bug.
>
> My setup is TC 4.0.1 stand-alone on RedHat 7.1 using the IBM JDK 1.2 -- in
> case anyone was wondering...
>
> --jeff
>
> ----- Original Message -----
> From: "August Detlefsen" <au...@yahoo.com>
> To: "Tomcat Users List" <to...@jakarta.apache.org>
> Sent: Friday, December 07, 2001 2:16 PM
> Subject: Re: Unable to include *.sum files (Again)
>
>
> > It might, if somewhere in the code of the <jsp:include> tag it
> > specifies to only include a file if it is of a relevant mime type, say
> > JSP, text/xyz, or image/abc.
> >
> > This would prevent the server from sending out potentially damaging
> > stuff with the include tag, like .java or .exe files.
> >
> > Again, I am just speculating...
--
To unsubscribe: <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>
Help: diff between tomcat 4.0 and tomcat 4.0.1
Posted by Nirmal Rajarathnam <ni...@fresher.com>.
My webapp which was working fine on tomcat 4.0 after I upgraded to
tomcat 4.0.1 has not worked since. Can someone tell me what is the
difference between both. I am running the server on Win 2000 with JDK
1.4 beta 3 on a stand-alone mode. The error seems to be where I call
getServletContext().getRequestDespatcher(location).forward(request,
response); (the last line in the error message dump)
Can someone help, point me the mistake.
Thanks,
Nirmal R.
____ Error Message _____
Apache Tomcat/4.0.1 - HTTP Status 500 - Internal Server Error
------------------------------------------------------------------------
type Exception report
messageInternal Server Error
descriptionThe server encountered an internal error (Internal Server
Error) that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Can not process
at com.company.product.module.ControllerServlet.doGet(ControllerServlet.java:113)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at com.company.product.module.KloverExceptionFilter.doFilter(KloverExceptionFilter.java:35)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:518)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
at java.lang.Thread.run(Thread.java:539)
Caused by: javax.servlet.ServletException: Servlet.init() for servlet jsp threw exception
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:871)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:615)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:648)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355)
at com.company.product.module.ControllerServlet.doGet(ControllerServlet.java:105)
... 37 more