I am defining a servlet in the web.xml file using the following syntax.
<servlet>
<servlet-name>TestServlet</servlet-name>
<jsp-file>/WEB-INF/index.jsp</jsp-file>
</servlet>
Then when I tried to access this servlet, I get a 404 not found error. The weblogic.log
file complains with the following message:
java.io.FileNotFoundException: no resource '/WEB-INF/index.jsp' in servlet context
root '/home/dev/web/apps/MyApp'
at weblogic.servlet.jsp.JspStub.compilePage(JspStub.java:293)
at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:227)
at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:200)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:115)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:922)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:886)
at weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:269)
at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:380)
at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:268)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
My jsp file in located in /home/dev/web/apps/MyApp/WEB-INF/index.jsp, I know weblogic
doesn't support jsp under WEB-INF, however, according to Sun's Servlet specification,
anything under web-inf should be accessible to getResource and getResourceAsStream
method, and it looks like that's what weblogic implementation is using (from the
error message). So I am not sure whether this is weblogic issue or I am doing
something wrong. By the way, the above config in web.xml is supported in Tomcat.
"Ming Fan" <mf...@lehman.com> wrote in message
news:3d77963b$1...@newsgroups.bea.com...
It is legal to put files under WEB-INF directory. But as mentioned in the
spec, it will be available only to servlet code and not directly to client
request.
Read the last statement of the same paragraph in section9.5.
"Since requests are matched to resource mappings case-sensitively, client
requests for '/WEB-INF/foo', '/WEb-iNf/foo', for example, should not result
in contents of the web application located under /WEB-INF being returned,
nor any form of directory listing thereof.".
So in your case, when you access the servlet which gets mapped to
/WEB-INF/your-jspfile, under no condition it should result in display of jsp
contents.
It is working as per the specification.
I hope this helps.
Regards,
Narayan Anand
Developer Relations Engineer
BEA WebLogic Support
"Ming Fan" <mf...@lehman.com> wrote in message
news:3d77...@newsgroups.bea.com...
Now here's another question. According to Web logic Customer Support Solution
ID S-12864 (WLS 6.x - Cannot access JSP under the WEB-INF directory), the servlet
should be able to get a request dispatcher, and then forward the request to the
jsp under WEB-INF. I am still using WLS 5.1, so does the above solution apply
to 5.1 also? It doesn't seem to work with 5.1. So is this a 5.1 problem and I
should upgrade to 6.1?
Thanks.
The story behind this is:
Our engineering team is already aware of the fact that the request
dispatcher calls (include/forward) for a jsp under the web-inf directory
works in other app server - Tomcat.
Our engineering team had a discussion with the servlet/jsp spec experts
group for clarifying the spec and the tomcat implementation.
So the servlet expert group has decided to explicitly state in the spec that
RD.forward() and RD.include() should be allowed access to resources in
/WEB-INF and it will be included in servlet spec 2.4. For now, WLS works as
per the current specification.
So far the story is - WLS will implement this in our next major release
which will be compliance with servlet spec 2.4.
In all the currently available WLS releases, accessed to a jsp under the
WEB-INF directory is prohibited.
--
Best Regards,
Narayan Anand
Developer Relations Engineer
BEA Systems, Inc.
"Ming Fan" <mf...@lehman.com> wrote in message
news:3d79...@newsgroups.bea.com...