aspose file tools*
The moose likes JSP and the fly likes How to determine page type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to determine page type" Watch "How to determine page type" New topic
Author

How to determine page type

Kudret Serin
Ranch Hand

Joined: Aug 02, 2005
Posts: 167

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

Joined: Aug 02, 2005
Posts: 167

any help ??
sannareddy sudheer
Greenhorn

Joined: Jul 16, 2003
Posts: 8
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

Joined: Jul 16, 2003
Posts: 8
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

Joined: Jan 10, 2002
Posts: 61010
    
  65

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
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.


Rizwan
SCJA, SCJP, SCWCD, SCBCD, SCDJWS.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to determine page type