help a simple expressions in jsp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bylum
    New Member
    • Mar 2007
    • 15

    #1

    help a simple expressions in jsp

    my problem is simple expressions in jsp
    like

    66.6666666%

    and

    i want change to

    66.7%

    it is my jsp coding

    out.printf("%2. 2f",totals);
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    What's the error then? Doesn't it compile? Are you using the correct Java version
    for your JSPs (1.5 or later)?

    kind regards,

    Jos

    Comment

    • bylum
      New Member
      • Mar 2007
      • 15

      #3
      Originally posted by JosAH
      What's the error then? Doesn't it compile? Are you using the correct Java version
      for your JSPs (1.5 or later)?

      kind regards,

      Jos
      my error is


      An error occurred at line: 173 in the jsp file: /z.jsp
      The method printf(String, double) is undefined for the type JspWriter

      173: out.printf("%2. 2f",totals);

      and i use tomcat 6.0.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by bylum
        my error is


        An error occurred at line: 173 in the jsp file: /z.jsp
        The method printf(String, double) is undefined for the type JspWriter

        173: out.printf("%2. 2f",totals);

        and i use tomcat 6.0.
        It's a compilation error then. Your 'out' object doesn't have that method. If your
        JspWriter is a Writer you can always wrap it in a PrintWriter; the latter definitely
        has that method implemented. Alternatively you can use a DecimalFormat
        object; check the API documents.

        kind regards,

        Jos

        Comment

        Working...