Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding two Strings in JSP

 
Sanketh Kumar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic