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 Adding two Strings in JSP 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 "Adding two Strings in JSP" Watch "Adding two Strings in JSP" New topic
Author

Adding two Strings in JSP

Sanketh Kumar
Greenhorn

Joined: May 28, 2008
Posts: 2
Hi,
Need a small favour in JSP.Actually,I have a display table column SharesTOX which was a double property in bean.What iam doing is fetching the data from Database and showing in the display table where one of the column is SharesTOX .If this property is double in bean,if data is not there in DB then it shows the default value "0.0".This should not happen in financial domain becoz,it has a value in financial domain.So If I want to add all the column values then its ok for double property.My problem is if data is not there in DB then that column should be blank.So for this I have changed the property in bean to String so that it will be blank if data is not there but the problem is when I try to add all the values of that column iam getting "ClassCastException"(I should get it).How to add the values of that column and also when data is not there in DB it should be blank.

Thanks in advance...


http:\\www.lover.java.com
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

Hi Sanketh Kumar welcome to Javaranch,

Please UseRealWords "becoz" is not a real word.

Are you fetching data using a bean or scriptlet. In both situations, when you get null value from the database, you can just display the empty string in the JSP.

but the problem is when I try to add all the values of that column iam getting "ClassCastException"(I should get it).


In this case you can use Double.parseDouble().

And take some time to read the ask good questions link below.

Hope this helps


SCJP, SCWCD.
|Asking Good Questions|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding two Strings in JSP
 
Similar Threads
Index column is null
Problem in getting data from MSAccess
JSP MySql
combobox ,how to get it from Table
Problem with default '' , 0 and 0.0 being inserted into database while using JSTL.