File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » JSP
Bookmark "JasperException from non-numeric parameter value" Watch "JasperException from non-numeric parameter value" New topic

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 bean:

The error page:

This happens if I call the JSP with an invalid parameter value, for instance

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

Joined: Jan 10, 2002
Posts: 63852

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).
[ July 02, 2003: Message edited by: Bear Bibeault ]

[Asking smart questions] [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.
I agree. Here's the link:
subject: JasperException from non-numeric parameter value
It's not a secret anymore!