如何阻止目录结构在J2EE应用程序中可见

Omn*_*ent 3 java directory-structure glassfish java-ee

在J2EE应用程序中,如果用户明确地取出结束页面名称,那么不显示目录结构的最佳方法是什么?

例:

/mycoolapp/somefolder/test.jsp

/mycoolapp/somefolder/  -- this will show all the files under 'somefolder'
Run Code Online (Sandbox Code Playgroud)

重定向或向用户显示"不属于您的位置"的页面的最佳方法是什么?我想避免在我的应用程序的所有文件夹/子文件夹中提供index.jsp.

正在使用的Appserver是GlassFish.该应用程序也使用Struts2框架,但并非所有代码都在struts2中.有些代码使用传统的Servlet

vkr*_*mer 8

我注意到你过去一直在询问有关GlassFish的问题,所以我想我会发现如何用GF来做这件事.如果您在不同的服务器上,这个答案可能是错误的,因为这种配置没有在J2EE或Java EE规范中定义.

在AS9/Glassfish世界中,config目录中有一个default-web.xml文件.寻找设置:

<init-param>
  <param-name>listings</param-name>
  <param-value>true</param-value>
</init-param>
Run Code Online (Sandbox Code Playgroud)

将"True"更改为"False".

找到此查询:http://www.google.com/search? q = glassfish +disable+directory + listing

在这篇博文中:http://blogs.oracle.com/bounds/entry/turning_off_directory_listings_in