aspose file tools*
The moose likes JSP and the fly likes JasperException from non-numeric parameter value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JasperException from non-numeric parameter value" Watch "JasperException from non-numeric parameter value" New topic
Author

JasperException from non-numeric parameter value

Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
If I call my JSP with a non-numeric parameter value, I get a Jasper-specific exception. Should I be somehow catching this exception, and if so, how? Doing so would make my JSP Tomcat-specific and thus non-portable, which seems like a very bad thing to do.
My JSP:

My bean:

The error page:

This happens if I call the JSP with an invalid parameter value, for instance
http://localhost:8080/budget/budget.jsp?expense=44a


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

What do you want to have happen in these circumstances?
Since request params come in as strings and nothing guarantees that they'll be valid, I'd change the bean mutators to accept a String as the value parameter, convert the string to numeric within the mutator, and deal with any parse exceptions (via any of: supply a default value, throw a meaningful exception, trigger a redirect to an error page... whatever makes the most sense for your app).
hth,
bear
[ July 02, 2003: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
I guess my question is:
Why am I getting a Jasper-specific exception instead of a standard-defined one? This situation must be quite common.
 
Consider Paul's rocket mass heater.
 
subject: JasperException from non-numeric parameter value