This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes Using aggregate sql (sum) in a jstl sql action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Using aggregate sql (sum) in a jstl sql action" Watch "Using aggregate sql (sum) in a jstl sql action" New topic
Author

Using aggregate sql (sum) in a jstl sql action

deb platt
Ranch Hand

Joined: Jan 23, 2008
Posts: 44
This is a problem that I couldn't find addressed on the web, but which I eventually figured out. Here's the scenario. I was trying to do this:




But I would get this error message:
Property 'COST' not found on type java.lang.String


Of course I could find the sum in my jsp as follows:



But I'd rather have the DBMS do the summing for me. So I tried this:



This actually worked. However since I knew I was only going to get a single value back from the query, I also tried replacing the loop with this:



That worked like a charm. ${clientShipping} now held the sum returned by the sql query.
[ September 24, 2008: Message edited by: deb platt ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Using aggregate sql (sum) in a jstl sql action
 
Similar Threads
How to use JSTL instead of scriptlet.This is about JDBC.
Why should an array variable be declared as a Bean
jdbc connection in jsp
Problem with displaying result of the query - JSTL
SQL Insert Statement Data Type Mismatch Error