开发者

how to stop directory structure from being viewable in J2EE apps

开发者 https://www.devze.com 2022-12-25 03:09 出处:网络
in a J2EE app if user explicitly takes out the the ending page name then what is the best way to not show the directory structure?

in a J2EE app if user explicitly takes out the the ending page name then what is the best way to not show the directory structure?

Example:

/mycoolapp/somefolder/test.jsp

/mycoolapp/somefolder/  -- this will show all the files under 'somefolder'开发者_Python百科

What is the best way to redirect or show the user a page saying 'not where you belong'. I want to avoid providing index.jsp in all the folders/subfolders of my application.

Appserver being used is GlassFish. Also the app is using Struts2 framework, though not all of the code is in struts2. Some code is using traditional Servlets


I noticed that you had been asking questions about GlassFish in the past, so I figured I would find out how to do this with GF. If you are on a different server, this answer is probably wrong, since this kind of configuration is not defined in the J2EE or Java EE specs.

In AS9/Glassfish world, there is a default-web.xml file in the config directory. Look for the setting:

<init-param>
  <param-name>listings</param-name>
  <param-value>true</param-value>
</init-param>

Change "True" to "False".

Found with this query: http://www.google.com/search?q=glassfish+disable+directory+listing

In this blog post: http://blogs.oracle.com/bounds/entry/turning_off_directory_listings_in

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号