how to do maths calculation in jsp?
4 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sher_low
Posted On:   Monday, July 19, 2004 06:29 PM

hi i would like to ask how can i set default hours for this category 'Total No. of Hours' in my webpage in which im supposed to retrieve the default hours from the database. And from the database, i am supposed to use 2 fields of which 1 is the 'Duration_Hrs' and another is the 'Duration_Days'. Therefore in order to set the default value for 'Total No. of Hours' i will have to take 'Duration_Days' multiply a default period of 8 hours followed by adding 'Duration_Hrs' otherwise the 'Total No. of Hours' will be retrieve from the database.

Re: how to do maths calculation in jsp?

Posted By:   Roy_Chew  
Posted On:   Monday, August 9, 2004 08:26 AM

Don't do any logic processing in your jsp,

instead do it in a separate Java class method and eventually,
place the result in an object field.

This object could then be treated as a JavaBean and
passed over in a request to the JSP.

If you passed an operand as a String, if would have to do the conversion before you could do the arithmetic.

You have do the math logic yourself,
can't help you there because I can't quite process your intentions.

Re: how to do maths calculation in jsp?

Posted By:   Anonymous  
Posted On:   Friday, July 23, 2004 03:38 AM



Hi
wat u can do is like
<%
if(attendedHours.equals("0"))
{
int hrs = durationDays*8+durationHours
out.print(hrs);
}
else
{
out.print(attendedHours);
}
%>

The problem would have that ur durationDays and DurationHours would have String ??? or else the out.println would have treated it as a numeric operation... u can do it in the way is said u....

Enoy Working
Shan.K.S
ksshan@rediffmail.com

Re: how to do maths calculation in jsp?

Posted By:   Aad_Nales  
Posted On:   Tuesday, July 20, 2004 08:52 AM

what is missing is a question...

Re: how to do maths calculation in jsp?

Posted By:   Aad_Nales  
Posted On:   Tuesday, July 20, 2004 08:52 AM

what is missing is a question...
About | Sitemap | Contact