Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

jsp-file="/WEB-INF/index.jsp" cannot load

0 views
Skip to first unread message

Ming Fan

unread,
Sep 5, 2002, 1:36:59 PM9/5/02
to

Hi,

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.

Jerrie Pineda

unread,
Sep 5, 2002, 4:03:19 PM9/5/02
to
Try moving it to a different dir. You normally don't place jsp file in the
WEB-INF dir.


"Ming Fan" <mf...@lehman.com> wrote in message
news:3d77963b$1...@newsgroups.bea.com...

Ming Fan

unread,
Sep 5, 2002, 6:09:06 PM9/5/02
to

Actaully there are other ways to solve my problem. But what I am interested to
know is under the Servlet specification 2.3, is it legal to put jsp under WEB-INF,
define it in <jsp-file> xml tag, and should the JSP compiler be able to see this
as a resource. Apparently, Tomcat allows this behavior, so does this mean Tomcat
conforms better to the Servlet spec, or Tomcat is wrong but Weblogic conforms
better? Can anyone let me know what's the correct interpretation of section 9.5
in servlet spec 2.3?

Narayan Anand

unread,
Sep 5, 2002, 10:04:15 PM9/5/02
to
Hi Ming,

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...

Ming Fan

unread,
Sep 6, 2002, 3:40:44 PM9/6/02
to

Thanks for the explanation. So this means weblogic treats such mapped servlet request
as a direct request to the jsp under WEB-INF, instead of forwarding it to some
JspCompiler servlet and let that compiler servlet use some resource loader to
load the jsp and then compile. I believe that latter implementation approach also
conforms the Servlet spec (it's a different way of treating the request, I guess).

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.

Narayan Anand

unread,
Sep 9, 2002, 4:09:38 PM9/9/02
to
Regarding S-12864 - It will not work as stated in the solution in any of
the available releases of WLS.
Please ignore that. I already informed the concerned person to correct the
solution.

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...

0 new messages