RequestDispatcher.forward() to resource under “/WEB-INF” doesn't work in WebSphere

限于喜欢 提交于 2019-12-05 02:28:22

问题


In one of my servlets, I invoke RequestDispatcher.forward() call to a static resource somewhere under WEB-INF folder:

request
    .getRequestDispatcher( "/WEB-INF/some/path/image.gif" )
        .forward( request, response );

Navigating to this servlet works fine under Tomcat, Jetty et al., but does not work in WebSphere 7. The error I get (both in the browser and in the server logs) is

Error 403: SRVE0190E: File not found: /WEB-INF/some/path/image.gif

Initially I assumed that WebSphere may need some specific configuration to allow internal forwarding to resources under WEB-INF, but I failed to google anything useful.

Any ideas why can this happen?

Thanks in advance!


回答1:


It appears that one should set exposeWebInfOnDispatch property to true in order to make WEB-INF accessible for servlets in WebSphere. I got this answer from WebSphere forum.


In WebSphere 7 administration console,

  1. Go to "Servers" => "Server Types" => "WebSphere application servers" on the left
  2. Choose proper server on the list on the main part of the page
  3. Click on "Container Settings" => "Web Container Settings" => "Web container"
  4. Go to "Custom properties" on the right
  5. Add new property:

    • Name: exposeWebInfOnDispatch
    • Value: true



回答2:


You are getting HTTP 403, which means forbidden. Try moving out image.gif out of WEB-INF. That might work



来源:https://stackoverflow.com/questions/20378230/requestdispatcher-forward-to-resource-under-web-inf-doesnt-work-in-websphe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!