java - How do I prevent directory listing in Jetty? -


basically have jetty server running @ local. can't access index.jsp file i see that

this web.xml file, see use apache cxf, , use spring, hibernate , jetty

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"          xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"          xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee                              http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"          version="3.1">        <context-param>          <param-name>contextconfiglocation</param-name>         <param-value>classpath:applicationcontext.xml,classpath:spring-security.xml</param-value>     </context-param>      <listener>         <listener-class>org.springframework.web.context.contextloaderlistener</listener-class>     </listener>      <!-- spring security start -->     <listener>         <listener-class>             org.springframework.web.context.request.requestcontextlistener         </listener-class>     </listener>      <filter>         <filter-name>springsecurityfilterchain</filter-name>         <filter-class>org.springframework.web.filter.delegatingfilterproxy         </filter-class>     </filter>     <!-- projenin ana url'inden itibaren spring security aktif ediliyor -->     <filter-mapping>         <filter-name>springsecurityfilterchain</filter-name>         <url-pattern>/*</url-pattern>     </filter-mapping>     <!-- spring security end -->     <servlet>         <servlet-name>cxfservlet</servlet-name>         <servlet-class>org.apache.cxf.transport.servlet.cxfservlet</servlet-class>          <load-on-startup>1</load-on-startup>     </servlet>      <servlet-mapping>         <servlet-name>cxfservlet</servlet-name>         <url-pattern>/*</url-pattern>     </servlet-mapping>  </web-app> 

how can resolve it. doing wrong ?

this has been answered in few places on stackoverflow. need set dirallowed parameter false on default servlet. can done either in web-inf/web.xml of servlet descriptor or providing modified etc/webdefault.xml file (via deploy module in jetty, example) loaded before of contexts.

in either file like:

<servlet>     <servlet-name>default</servlet-name>     <servlet-class>org.eclipse.jetty.servlet.defaultservlet</servlet-class>     ....     <init-param>         <param-name>dirallowed</param-name>         <param-value>false</param-value>     </init-param>     .... </servlet> 

as user eng.fouad points out can defined context parameter:

<context-param>     <param-name>org.eclipse.jetty.servlet.default.dirallowed</param-name>     <param-value>false</param-value> </context-param> 

Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -