1

I have added a dynamic web project in Eclipse and can access the static HTML files and resources in the WebContent folder. I have placed my JSP files in WebConent\WEB-INF

This works fine: "http://localhost:8080/HelloWorld/index.htm"

This tells me the resource is not found: "http://localhost:8080/HelloWorld/Logon.jsp"

I have not defined any JSP servlet mappings. I have the default web.xml which only has the welcome files in it. I right click the project name and choose Debug On Server to run the app.

Update: I've had some success. I added the following to the Eclipse project's web.xml (in the WebContent\WEB-INF folder). The Test.jsp works as "http://localhost:8080/HelloWorld/Test.jsp" only when Test.jsp is in the WebContent folder and not when its in the WebContent\WEB-INF folder.

  <servlet>
   <servlet-name>jsp</servlet-name>
   <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
   <init-param>
       <param-name>fork</param-name>
       <param-value>false</param-value>
   </init-param>
   <init-param>
       <param-name>xpoweredBy</param-name>
       <param-value>false</param-value>
   </init-param>
   <init-param>
        <param-name>logVerbosityLevel</param-name>
        <param-value>WARNING</param-value>
   </init-param>
   <load-on-startup>3</load-on-startup>

   <servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>*.jsp</url-pattern>
   </servlet-mapping>
glez
  • 1,170
  • 3
  • 16
  • 42
  • Do you have a Logon.jsp. Does the logs show any problem? – Thorbjørn Ravn Andersen Oct 15 '12 at 22:43
  • Yes Logon.jsp is there. I removed all files and have only a Test.jsp in the WEB-INF folder and that has 1 line of text in it. There's no logs in the tomacat\logs folder. Should I be looking elsewhere for logs? – glez Oct 15 '12 at 23:14
  • There is this warning in the console window: WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:HelloWorld' did not find a matching property. – glez Oct 15 '12 at 23:17

1 Answers1

2

Files in /WEB-INF are not publicly accessible. That folder is intented for configuration files, template files, tag files, include files, MVC view files, etcetera. Basically everything which is not supposed to be directly accessible by the enduser without invoking some main JSP file or a front controller servlet first.

Just put them outside the /WEB-INF folder, in the public webcontent.

See also:


Don't forget to remove the unnecessary copy of the JspServlet from your web.xml. It didn't solve the concrete problem at all. Even more, it really doesn't belong there in your webapp's web.xml. It is already definied in servletcontainer's own web.xml (in case of Tomcat you can find it in its /conf folder. Registering the JspServlet in your webapp's web.xml would only make your webapp unportable. It wouldn't be able to run on a servletcontainer of a different make than Tomcat.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Perfect! It worked. I originally had all the files in a sub folder of WebContent and moved them to WEB-INF but was given advise to move them into WEB-INF. Thanks for the help. – glez Oct 16 '12 at 00:38