0

1.

if run startup.bat in cmd can not see in web

apache-tomcat-6.0.30\webapps\AbstractCommandDemo\WebContent\WEB-INF\index.html
apache-tomcat-6.0.30\webapps\AbstractCommandDemo\WebContent\WEB-INF\jsp\userInfo.jsp
localhost:8080/AbstractCommandDemo/userInfo.jsp
localhost:8080/AbstractCommandDemo/user.do
localhost:8080/AbstractCommandDemo/WEB-INF/jsp/userInfo.jsp

can see in web

apache-tomcat-6.0.30\webapps\AbstractCommandDemo\index.html

2. Moreover, if running through eclipse, worse than above situation, can not see index.html in http://localhost:8080/ which is apache-tomcat-6.0.30\webapps\AbstractCommandDemo\index.html

<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>AbstractCommandController Demo</title>
</head>
<body>
    <h1>name:${userInfo['name']}</h1>
    <h1>password:${userInfo['password']}</h1>
</body>
</html>

web.xml

<session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>

    <servlet>
        <servlet-name>dispatcherServlet</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/mvcconfig.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>dispatcherServlet</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>

mvcconfig.xml

 <bean id="urlMapping" 
          class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> 
        <property name="mappings"> 
            <props> 
                <prop key="/user.do">userController</prop> 
            </props> 
        </property> 
    </bean> 

    <bean id="viewResolver" 
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
        <property name="prefix" value="/WEB-INF/jsp/"/> 
        <property name="suffix" value=".jsp"/> 
    </bean> 

    <bean id="userController" 
          class="onlyfun.caterpillar.UserController"> 
        <property name="userPage" value="userInfo"/> 
    </bean> 
AlexR
  • 114,158
  • 16
  • 130
  • 208
Jo0o0
  • 531
  • 2
  • 18
  • 31
  • Did your application deploy successfully? Are there errors in server logs? – Guillaume Jan 14 '11 at 07:44
  • i copy the example to the folder of apache webapps, and apache can see the cat index page, no configuration is done, everything is normal – Jo0o0 Jan 18 '11 at 04:22

2 Answers2

2

pages in WEB-INF and META-INF folders are automatically protected from external access. Just move the pages you want to serve out of the two folders and you should be able to see your pages already.

tanyehzheng
  • 2,201
  • 1
  • 20
  • 33
  • Any other method as i need to preserve the directory hirecharcy – Jo0o0 Jan 18 '11 at 04:23
  • You can include the protected pages in other accessible pages. You can do some other hacks as well. But all these hacks are NOT recommended. Please reconsider why you must put those files inside the protected folders. – tanyehzheng Aug 23 '13 at 01:45
0

in the tomcat webserver WEB-INF And MATA-INF dir is protectd so no one can access file from out sides

so you can call your file only form the servlet

if you are using jsp in WEB-INF / Jsp folder then you can you have to write servlet that can call your jsp file this is very secure way

other wise it will give you 404 error

write servlet that call your jsp or redirect your jsp in WEB-INF / Jsp Folder

NAYAN RAMI
  • 365
  • 1
  • 7
  • 17