473,503 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculate sum of values in column in a tabel

2 New Member
I had a table with 3 columns and 4 rows in website view. I need to add the column values and show at the bottom of the table as total. I'm using spring mvc3. How can I calculate the sum in JSP?
am using spring mvc3 in java
but this code i got in internet. and it's input type is "text". and my requirement is to add the values of a column retrieved from db to the table
Attached Images
File Type: jpg Snap 2014-10-11 at 23.40.30.jpg (10.1 KB, 298 views)
Oct 11 '14 #1
1 2953
chaarmann
785 Recognized Expert Contributor
How can I calculate the sum in JSP?
You should not calculate the sum in JSP page. Read about MVC (Model-View-Controller). You should not do it in the view, but do it in the model. That means you should do it in the servlet code.

but this code i got in internet and it's input type is "text"
I do not understand. What code are you talking about? Please quote the code here.

Usually a number is stored in a database column of type number or Decimal and not text. So if you retrieve the value, you can directly read it into a long or int variable. If it is text, you can convert it to a long or int with Integer.parseInt() or Long.parseLong().
Then you just sum up all values with sum = sum + newValue

By the way, the attached image is so small and has such a bad resolution that I cannot read anything even if I zoom it.
Oct 14 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
3658
by: DMAC | last post by:
If i want to split a computed column into two or more columns based on the the length (its a varchar) of the computed column, how often will sql server determine what the computed column is?...
1
1525
by: ferky | last post by:
I have this code below when I asign strOldTkinit = strNewTkinit and then read the new value for the strNewTkinit from the recordset the strOldTkinit changes the value also. So when I run my...
1
2214
by: tomektomeknyc | last post by:
I did an interactive program to input and store employee paycheck information including total net pay into txt file. I can read it from txt file but how can i lets say modify it to calculate the...
0
1779
by: Manish | last post by:
Hey Guys I am using a datagrid to extract information out of SQL Server datbase. The fields extracted are category,week,budget,Last Year,Forecast and Projection. Also i add a calculated column...
1
1432
by: jchimanzi | last post by:
How can i rewrite the following code correcting all problems found void calculatevalues (const int &a, float *b, int &c) { d = 20.4; if (*a =0) *a += 1
1
1521
by: manojsingh | last post by:
hi, I am generating combo.All combo has diffrent names. combo contain three values - L,EL and LWP Agian there is three text box that shows the rest CL,EL,LWP values which is not editable....
2
1349
by: Bezualem | last post by:
hi there I am new for SQL server please help me to calucate tow different column. Thank you in advance. Bezualem
1
2835
by: shalit.dror | last post by:
I have an XML files that contains grades in different subjects from year 2005  2007 . In the HTML file I have several drop down list that contain all the names of the subjects. If I select for...
0
1504
by: Steve Kirby | last post by:
You can't ... What you might try is: desc tabe1 This will list the columns in that table. You can select what you want to pull from that way.
1
1707
by: ekariuki | last post by:
Hallo, I have a table Routes that contains a route name and when the route runs. I would like to calculate the difference between the last run Day and the one after it. This will populate in the...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7274
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4670
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1507
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.