开发者

JSF application giving 404 for a sub-context

I am working on a web application which uses JSF. I have a folder called 'admin' under 'web' and I have couple of jsp pages under folder 'admin'. I can access jsp pages under 'web' but when I try to access the pages under 'admin' I get '404-Requested resource cannot be f开发者_Go百科ound' The 'context.xml' for my application is something like this:

<Context antiJARLocking="true" path="/MyApp"/>

This thing works on my local tomcat but when I deploy this to my web hosting providers tomcat I have above mentioned problem. What exactly I need to do to fix this problem.

Here is server.xml for my application on the Hosting provides tomcat:

<Host name="myapp.com" appBase="/home/myapp/public_html">
      <Alias>www.myapp.com</Alias>
      <Context path="" reloadable="true" docBase="/home/myapp/public_html" debug="1"/>
      <Context path="/manager" debug="0" privileged="true"
          docBase="/usr/local/jakarta/tomcat/server/webapps/manager">
      </Context>
   </Host>

Or do I need to add URL-Mapping to my web.xml?

I have following servlet filter in the web.xml for '/admin/*' url-pattern

    <filter>
    <filter-name>SecurityFilter</filter-name>
    <filter-class>com.myapp.SecurityFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>SecurityFilter</filter-name>
    <url-pattern>/admin/*</url-pattern>
</filter-mapping>

And the filter code is as follows:

    public void doFilter(ServletRequest request, ServletResponse response, 
                     FilterChain chain) throws IOException, ServletException {

    lgMgr.logDebug("doFilter() is called...");
    String validuser = null;
    HttpServletRequest req = (HttpServletRequest) request;
    HttpServletResponse res = (HttpServletResponse) response;                        
    HttpSession session = req.getSession(true);        

    //If authorization key not in session, redirect to login page.
    validuser = (String) session.getAttribute(Common.AUTH_USER);

    if(validuser != null) {
        lgMgr.logDebug("doFilter(): User is allowed to access the page...");
        //If the user is allowed access to the URI, let the flow proceed as normal
        chain.doFilter(request, response);
        return;
    } else {
        lgMgr.logDebug("doFilter(): User is not allowed to access the page, redirecting user login...");
        //User not allowed access - redirect to login page
        res.sendRedirect(req.getContextPath() +  "/AdmLogin.jsf");
        return;
    }
}


Files in /WEB-INF are not public accessible. I have no idea why it works locally, but this violates the servlet specification. Also, JSF cannot forward views to JSP pages in /WEB-INF folder, they should be placed in public webcontent (one folder level up above /WEB-INF folder).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜