File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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: 60780
    
  65

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JasperException from non-numeric parameter value
 
Similar Threads
Trouble writing to bean
jsp/bean/tomcat
jsp weekend crash course - chapter 11
jsp:getProperty calling bean from specific scope
jsp:useBean doubt