I have a MVC website with java technologies. I have a number of .jsp which when routed to via proper servlets work fine, but when accessed directly appear not to work. I want to prevent my users from direct addressing the .jsps.
That is they can use www.url.com/Website/MyServlet, which would then forward them to www.url.com/Website/MyServlet.jsp, but I want to prevent them from direct addressing towww.url.com/Website/MyServlet.jsp since the HttpServletRequest will be missing attributes and will not display correctly. Surely this must be common practice? How do I accomplice this, can I write a mapping which redirects all *.jsp to not founds unless it is a forward?
I bet I could write a filter that picks up all non FORWARD directives (INCLUDE REQUEST etc) mapped to *.jsp and send 404 for them but Im thinking there must be a eaisier way? Anyone have any suggestions?
Put them in
/WEB-INFfolder and change the forward paths accordingly.Files in
/WEB-INF(and/META-INF) folder are not publicly accessible.