While not using a framework like Hibernate, I recall coding for an exception in 
the servlet itself. Then throwing an exception to get to the error page.
Not sure if that helps you or not. 

-----Original Message-----
From: Yucca Nel [mailto:yucca...@live.co.za] 
Sent: Wednesday, May 12, 2010 2:15 AM
To: Tomcat Users List
Subject: Re: error-page exception-type subclasses of RuntimeException are not 
handled

I thought I would like to add to thepoint I am trying to make,.... I am using 
hibernate validation API and get big fat runtime exceptions if the validation 
API fails a check on a field that has certain validations like length etc. 
These excceptions are avoidable (some of them) from the point that the data is 
entered snd I can ask user for correct data  (or more reasonable data)

Lets say I have an email field in UserEntity as follows....
 @Email
    public String getUserEmail() {
        return userEmail;
    }

It is the job of the business layer to 1 decide on valid emails (like we only 
accept hotmail) if such logic applies) and it is the job of the view to find 
incorrect emails as soon as possible to avoid an expensive rountrip for the 
sake of a user using the application.

--------------------------------------------------
From: "Yucca Nel" <yucca...@live.co.za>
Sent: Wednesday, May 12, 2010 9:03 AM
To: "Tomcat Users List" <users@tomcat.apache.org>
Subject: Re: error-page exception-type subclasses of RuntimeException are not 
handled

> I am not too sure on this, but it could be because runtime exceptions 
> are usually avoidable and perhaps therefore you need to deal with such 
> errors beforehand(higher up in the stack) and throw custom exceptions. 
> It doesn't sound like good coding standards(what you are doing 
> anyway). If you are using JSF you can use<from-outcome> to control 
> views for user error to redirect them to error page.
>
> --------------------------------------------------
> From: "bryan jacobs" <bryancjac...@hotmail.com>
> Sent: Wednesday, May 12, 2010 12:56 AM
> To: <users@tomcat.apache.org>
> Subject: error-page exception-type subclasses of RuntimeException are 
> not handled
>
>>
>>
>> Tomcat Version: apache-tomcat-6.0.26
>>
>> JDK: jdk1.6.0_19
>>
>> OS: Windows XP Service Pack 2
>>
>> I am using the <page-error> element in my web.xml with the 
>> <exception-type> element which contains a subclass of RuntimeException.
>>
>> When I subclass RuntimeException the <location> element which 
>> specifies my error-page to land on in the event that exception is 
>> raised is not displayed.
>>
>>
>> web.xml snippet:
>>
>>    <error-page>
>>
>> <exception-type>org.lds.lua.directory.exception.LuaSecurityException</exception-type>
>>        <location>/error.html</location>
>>    </error-page>
>>
>> Where LuaSecurityException extends RuntimeException
>>
>> When my JAX-RS method throws the LuaSecurityException the error.html 
>> is NOT displayed.
>>
>> However, if I change the above configuration to:
>>
>>
>>
>>    <error-page>
>>
>>
>> <exception-type>java.lang.RuntimeException</exception-type>
>>
>>        <location>/error.html</location>
>>
>>    </error-page>
>>
>> and have my class throw a RuntimeException then the error.html page 
>> is displayed.
>>
>> Finally if I change the web.xml to:
>>
>>    <error-page>
>>
>>
>>
>> <exception-type>java.lang.Exception</exception-type>
>>
>>
>>        <location>/error.html</location>
>>
>>
>>    </error-page>
>>
>> and my jax-rs class throws a LuaSecurityException extends 
>> RuntimeException then my error.html is displayed.
>>
>> What I would like to do is:
>>    <error-page>
>>
>>
>> <exception-type>org.lds.lua.directory.exception.LuaSecurityException<
>> /exception-type>
>>
>>        <location>/error.html</location>
>>
>>    </error-page>
>>
>> That way I can create various RuntimeException subclasses which are 
>> appropriate for my application and handle them with specific error pages.
>>
>> Any help would be appreciated.
>>
>> If you need more information please let me know.
>>
>> Bryan
>>
>> _________________________________________________________________
>> Hotmail is redefining busy with tools for the New Busy. Get more from 
>> your inbox.
>> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTA
>> GL:ON:WL:en-US:WM_HMP:042010_2
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to