I have question, in flow of my application i need to determine if the current pagetype is errorPage or not.How to get the value of isErrorPage attribute used withing page directive ? Is there any way to get this, other than that also i wonder if it is possible to get value of directive attributes ?
Thanks in advance [ July 02, 2007: Message edited by: Kudret Serin ]
in page directive (<%@ page ) it has two attributes 1)errorPage 2)isErrorPage. when any exception occurs in your pplication to show the user friendly message to the user you can define a jsp(errorpage) by specifying the 'isErrorPage='true'' in the page directive like <%@ page isErrorPage="true" %> and in all other JSP pages you need to set this error page URL to the errorPage attribute of the 'page' directive like '<%@ page errorPage="jsp/errorPage.jsp" %>' . what it does is if any exception occurs in any of your JSPs it redirects that exception to the JSP which is mentioned in 'errorPage' URL.
by defaulat 'isErrorPage' is set to 'false' , if you set 'isErrorPage="true" in any JSP , the implicit object 'Exception' will be available to that JSP page.
An error page should only be invoked as a result of the container detecting an uncaught exception. As such, you should be never be in a position to have to know whether it's an error page or not.
This and your other post regarding error pages leads me to suspect that you are using error pages in inappropriate ways, Perhaps you could explain to us what it is you are actually trying to accomplish and we can advise on the best ways to accomplish it. [ July 02, 2007: Message edited by: Bear Bibeault ]
I'm not sure whether you can findout whether the current page is error page or not by reading directive attributes. I have one suggestion but I dont know whether it works or not? Use reflection mechanism to find all variables in jsp. If variable exception is defined in jsp then it is error page!! I am wondering, what use case is making you to write that logic? Anyway, best of luck.
Originally posted by Rizwan Mohammad: I'm not sure whether you can findout whether the current page is error page or not by reading directive attributes. I have one suggestion but I dont know whether it works or not? Use reflection mechanism to find all variables in jsp. If variable exception is defined in jsp then it is error page!! I am wondering, what use case is making you to write that logic? Anyway, best of luck.
Before diving into reflection, I'd read Bear's post. Let us know what you're trying to do. Maybe we can suggest another approach.