• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to determine page type

 
Kudret Serin
Ranch Hand
Posts: 167
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

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 ]
 
Kudret Serin
Ranch Hand
Posts: 167
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any help ??
 
sannareddy sudheer
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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.

i hope it helps.
 
sannareddy sudheer
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to add a few more points:

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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


I agree with you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic