简体   繁体   中英

getRequestDispatcher returning null even though path/file exists in webapp

I am trying to get a login page from within a Filter, like so: context.getRequestDispatcher("/loginpage.jsp") (Which I then want to forward to)

Now, if i do context.getContext("/loginpage.jsp"), it properly shows me the filesystem path to the resource I want. So that means it can indeed see it. However using request dispatcher it just wont resolve.

I am running this tomcat in a very non standard way. I am calling java.exe with all the properties and options that catalina.sh normally would call. I would agree that this could be the cause of all my problems, but I am still interested in finding out what could be breaking in here.

(Note: This runs like this only in dev environments and has been working properly without complains till recently. However I recently made major changes to the dev env, which apparently broke something)

EDIT: Another point I just noticed was, that even trying to access completely static resources (like /css/styles.css, etc) was failing. So it isnt a specific problem with getrequestDispatcher, but something more fundamental I presume?

The solution was really simple and down to a misunderstanding of how the CATALINA_HOME / CATALINA_BASE works: Anything placed in CATALINA_HOME/conf seems to be ignored. So even though I had web.xml and content.xml in the CATALINA_HOME/conf it ignored that.

There are no exceptions or errors in any of the logs (application logs, catalina.logs, localhost.log, host-managed.log, etc). So it is really hard to debug this problem.

This question helped me figure the answer out: https://serverfault.com/questions/205154/war-deployed-in-tomcat-not-showing-up-at-url-getting-404-instead

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM