<c:catch> and <fmt:parseNumber> not working

Discussion in 'Java' started by Derek Mahar, Aug 27, 2003.

  1. Derek Mahar

    Derek Mahar Guest

    Why does Tomcat 5.0.9 throw exception java.lang.NumberFormatException
    when it executes the following JSTL code with amount equal to "asdf"?
    Shouldn't <c:catch> catch the exception, assign the error code to
    amountError, and allow Tomcat to continue processing the page?

    Configuration:
    JSTL 1.1 in Sun Java Web Services Developer Pack 1.2
    Tomcat 5.0.9

    <%-- Validate amount. --%>
    <c:catch var="amountError">
    <%-- Parse the amount entry to see if it is a valid integer and to
    remove commas and decimals. --%>
    <fmt:parseNumber
    var="parseAmount"
    value="${amount}"/>

    <%-- Check that order amount is not zero. --%>
    <c:if test="${amount == 0}" var="isZeroAmount"/>
    </c:catch>
    <c:if test="${not empty amountError}" var="isBadAmount"/>

    HTTP Status 500 -

    ------------------------------------------------------------------------------

    type Exception report

    message

    description The server encountered an internal error () that prevented
    it from fulfilling this request.

    exception

    javax.servlet.ServletException: In <formatNumber>, value attribute can
    not be parsed into java.lang.Number: "asdf"
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:679)
    org.apache.jsp.Trader.ActionOrderCreate_jsp._jspService(ActionOrderCreate_jsp.java:91)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:293)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

    root cause

    java.lang.NumberFormatException: For input string: "asdf"
    java.lang.NumberFormatException.forInputString(Unknown Source)
    java.lang.Long.parseLong(Unknown Source)
    java.lang.Long.valueOf(Unknown Source)
    org.apache.taglibs.standard.tag.common.fmt.FormatNumberSupport.doEndTag(FormatNumberSupport.java:190)
    org.apache.jsp.tag.web.formatAmount_tag._jspx_meth_fmt_formatNumber_0(formatAmount_tag.java:101)
    org.apache.jsp.tag.web.formatAmount_tag.doTag(formatAmount_tag.java:54)
    org.apache.jsp.tag.web.orderEnter_tag._jspx_meth_bond_formatAmount_0(orderEnter_tag.java:1281)
    org.apache.jsp.tag.web.orderEnter_tag.doTag(orderEnter_tag.java:287)
    org.apache.jsp.Trader.ActionOrderCreate_jsp._jspx_meth_bond_orderEnter_0(ActionOrderCreate_jsp.java:120)
    org.apache.jsp.Trader.ActionOrderCreate_jsp._jspService(ActionOrderCreate_jsp.java:68)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:293)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

    note The full stack trace of the root cause is available in the Tomcat
    logs.

    ------------------------------------------------------------------------------

    Apache Tomcat/5.0.9

    Derek
    Derek Mahar, Aug 27, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. klikic

    JSTL fmt:setLocale problem

    klikic, Apr 28, 2006, in forum: Java
    Replies:
    0
    Views:
    4,654
    klikic
    Apr 28, 2006
  2. jill
    Replies:
    0
    Views:
    1,017
  3. tempsl

    Implementing Unix fmt ( ) function

    tempsl, Nov 16, 2005, in forum: C Programming
    Replies:
    0
    Views:
    415
    tempsl
    Nov 16, 2005
  4. Josef 'Jupp' SCHUGT

    string#fmt - breaking lines (no indent)

    Josef 'Jupp' SCHUGT, Apr 28, 2005, in forum: Ruby
    Replies:
    2
    Views:
    113
  5. Markus Kolb
    Replies:
    1
    Views:
    97
    Markus Kolb
    Nov 1, 2006
Loading...

Share This Page