views:

749

answers:

2

i have a number of jsp files under web-inf folder. Inside my web.xml i specify an errorppage for 404 amd 403 and java.lang.exception. Do i need to include a page directive for each of my jsp's or will they automatically get forwarded to the exception handling page because they are under web-inf?

If this is true does this mean that jsps which are not placed under web-inf do need to have the page directive added in order to forward them to the exception handling page?

thank you , im just trying to understand the consequences of web-inf

+1  A: 

You just need to have whatever errorpage you would like to use in your app available with all the other jsps. So in the following example you would just need to have the error pages in the root of the context path(where all of the other jsps are). Anytime the webapp receives a 404 or 403 error it will try to display one of these pages. .

<error-page> 
   <error-code>404</error-code> 
   <location>/404Error.jsp</location> 
</error-page>
<error-page> 
   <error-code>403</error-code> 
   <location>/403Error.jsp</location> 
</error-page>

Just make sure 404Error.jsp and 403Error.jsp contain:

<%@ page isErrorPage="true" %>

If you are actually using jsps for error pages (instead of just static html)

Steve g
A: 

ok so just to clarify; my jsps dont need to be in the web-inf folder in order for my web descriptor to pick up the exception and forward to the error page