You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Stefano Tranquillini <st...@gmail.com> on 2009/04/21 17:34:07 UTC

How to do matematical operation in jsp.

Hi all
i've a hashmap that contains object and a value(int).

i would display all the value of the object:

   <s:iterator value="#session.cart.items">
             <s:property value="key.name" />
              <s:property value="key.price" />x<s:property value="value" />
   </s:iterator>

and a value calculated at runtime that is a moltiplication of:
<s:property value="key.price" /> and <s:property value="value" />

how can i do that?

thanks

-- 
Stefano

Re: How to do matematical operation in jsp.

Posted by Dave Newton <ne...@yahoo.com>.
Jim Kiley wrote:
> EVIL, wow, sounds serious.

I just tested BigDecimal math in JSP/OGNL and the room started smelling 
like sulfur.

Sure, it could have been the huevos rancheros, but I'm pretty sure it 
was the math in the JSP.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by mitch gorman <mg...@shadowtv.com>.
    and remember, STAY AWAY FROM THE PATH OF EEEEEEVILLE!


Jim Kiley wrote:
> EVIL, wow, sounds serious.
>
> On Tue, Apr 21, 2009 at 12:02 PM, Lukasz Lenart <
> lukasz.lenart@googlemail.com> wrote:
>
>   
>> 2009/4/21 Suneel <su...@gmail.com>:
>>     
>>> I'm not sure about this but can't you invoke a function in OGNL. I
>>> guess thats how the getText function works in ognl. Probably you can
>>> write a function in your action like getResult and invoke it using
>>> <s:property value="getResult(key.price,value)"/>
>>> Correct me if i'm wrong.
>>>       
>> Yes you can do that, but it's EVIL! DON'T DO THAT!!! Business logic
>> has to be in your business model, not in a presentation layer!
>>     


-- 
Mitch Gorman
mgorman@shadowtv.com
(215) 764-6310
Skype: mitch.shadowtv.com


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by Jim Kiley <jh...@summa-tech.com>.
EVIL, wow, sounds serious.

On Tue, Apr 21, 2009 at 12:02 PM, Lukasz Lenart <
lukasz.lenart@googlemail.com> wrote:

> 2009/4/21 Suneel <su...@gmail.com>:
> > I'm not sure about this but can't you invoke a function in OGNL. I
> > guess thats how the getText function works in ognl. Probably you can
> > write a function in your action like getResult and invoke it using
> > <s:property value="getResult(key.price,value)"/>
> > Correct me if i'm wrong.
>
> Yes you can do that, but it's EVIL! DON'T DO THAT!!! Business logic
> has to be in your business model, not in a presentation layer!
>
>
> Regards
> --
> Lukasz
> http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Jim Kiley
Senior Technical Consultant | Summa
[p] 412.258.3346
http://www.summa-tech.com

Re: How to do matematical operation in jsp.

Posted by Lukasz Lenart <lu...@googlemail.com>.
2009/4/21 Suneel <su...@gmail.com>:
> I'm not sure about this but can't you invoke a function in OGNL. I
> guess thats how the getText function works in ognl. Probably you can
> write a function in your action like getResult and invoke it using
> <s:property value="getResult(key.price,value)"/>
> Correct me if i'm wrong.

Yes you can do that, but it's EVIL! DON'T DO THAT!!! Business logic
has to be in your business model, not in a presentation layer!


Regards
-- 
Lukasz
http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by Suneel <su...@gmail.com>.
I'm not sure about this but can't you invoke a function in OGNL. I
guess thats how the getText function works in ognl. Probably you can
write a function in your action like getResult and invoke it using
<s:property value="getResult(key.price,value)"/>
Correct me if i'm wrong.


On Tue, Apr 21, 2009 at 10:34 AM, Stefano Tranquillini
<st...@gmail.com> wrote:
> Hi all
> i've a hashmap that contains object and a value(int).
>
> i would display all the value of the object:
>
>   <s:iterator value="#session.cart.items">
>             <s:property value="key.name" />
>              <s:property value="key.price" />x<s:property value="value" />
>   </s:iterator>
>
> and a value calculated at runtime that is a moltiplication of:
> <s:property value="key.price" /> and <s:property value="value" />
>
> how can i do that?
>
> thanks
>
> --
> Stefano
>



-- 
Thanks
Suneel

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by Dave Newton <ne...@yahoo.com>.
Stefano Tranquillini wrote:
> and a value calculated at runtime that is a moltiplication of:
> <s:property value="key.price" /> and <s:property value="value" />
> 
> how can i do that?

Does <s:property value="%{key.price * value}"/> not work?

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by Dave Newton <ne...@yahoo.com>.
Lukasz Lenart wrote:
> 2009/4/21 Dave Newton <ne...@yahoo.com>:
>>>> And the next step will be implement whole bank security in jsp :P
> 
>> Right, because that's clearly the type of "trivial functionality" I was
>> talking about. Don't be ridiculous.
> 
> Young programmers very often follow such advices and extend logic in
> jsp, they have a problem to see borders of "trivial functionality". It
> wasn't joke, really :-(

Sure. That doesn't negate anything I said, though.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by Stefano Tranquillini <st...@gmail.com>.
<s:property value="key.price * value" />
works!


On Tue, Apr 21, 2009 at 18:56, Lukasz Lenart
<lu...@googlemail.com>wrote:

> 2009/4/21 Dave Newton <ne...@yahoo.com>:
> >>> And the next step will be implement whole bank security in jsp :P
>
> > Right, because that's clearly the type of "trivial functionality" I was
> > talking about. Don't be ridiculous.
>
> Young programmers very often follow such advices and extend logic in
> jsp, they have a problem to see borders of "trivial functionality". It
> wasn't joke, really :-(
>
>
> Regards
> --
> Lukasz
> http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Stefano

Re: How to do matematical operation in jsp.

Posted by Lukasz Lenart <lu...@googlemail.com>.
2009/4/21 Dave Newton <ne...@yahoo.com>:
>>> And the next step will be implement whole bank security in jsp :P

> Right, because that's clearly the type of "trivial functionality" I was
> talking about. Don't be ridiculous.

Young programmers very often follow such advices and extend logic in
jsp, they have a problem to see borders of "trivial functionality". It
wasn't joke, really :-(


Regards
-- 
Lukasz
http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by Dave Newton <ne...@yahoo.com>.
mitch gorman wrote:
> Lukasz Lenart wrote:
>> And the next step will be implement whole bank security in jsp :P

...

Right, because that's clearly the type of "trivial functionality" I was 
talking about. Don't be ridiculous.

>> Don't teach people such a things, jsp is only for presentation! What
>> will happen when the presentation layer will change or someone starts
>> using REST plugin? He wouldn't be aware of such logic, hidden in jsp.

Your dogmatic approach to what does, and doesn't, belong in the 
presentation layer will find zero traction with me.

I will never, however, say that the use of any OGNL expression is always 
a bad thing, or that there is never a place for decision-making or data 
manipulation in a JSP page. 'Nuff said.

>     we took a vote, dave.  i'm afraid you're going to have to turn off
> cookies in your browser for the rest of the day.

Curses.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by mitch gorman <mg...@shadowtv.com>.
Lukasz Lenart wrote:
> 2009/4/21 Dave Newton <ne...@yahoo.com>:
>   
>>> How do you want to test it? I know it's a simple case, but it's better
>>> to have logic in one place.
>>>       
>> As I said, I'm easily convinced in this particular case.
>>
>> OTOH, there are plenty of times when it's simply easier, quicker, and
>> clearer to just implement trivial functionality in the JSP.
>>     
>
> And the next step will be implement whole bank security in jsp :P
> Don't teach people such a things, jsp is only for presentation! What
> will happen when the presentation layer will change or someone starts
> using REST plugin? He wouldn't be aware of such logic, hidden in jsp.
>   

    we took a vote, dave.  i'm afraid you're going to have to turn off
cookies in your browser for the rest of the day.



-- 
Mitch Gorman
mgorman@shadowtv.com
(215) 764-6310
Skype: mitch.shadowtv.com


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by Lukasz Lenart <lu...@googlemail.com>.
2009/4/21 Dave Newton <ne...@yahoo.com>:
>> How do you want to test it? I know it's a simple case, but it's better
>> to have logic in one place.
>
> As I said, I'm easily convinced in this particular case.
>
> OTOH, there are plenty of times when it's simply easier, quicker, and
> clearer to just implement trivial functionality in the JSP.

And the next step will be implement whole bank security in jsp :P
Don't teach people such a things, jsp is only for presentation! What
will happen when the presentation layer will change or someone starts
using REST plugin? He wouldn't be aware of such logic, hidden in jsp.


Regards
-- 
Lukasz
http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by Dave Newton <ne...@yahoo.com>.
Lukasz Lenart wrote:
> 2009/4/21 Dave Newton <ne...@yahoo.com>:
>> Meh--for simple stuff like this I'm not as sure, although if we're talking
>> about a line item in a invoice, it wouldn't take much to convince me.
> 
> How do you want to test it? I know it's a simple case, but it's better
> to have logic in one place.

As I said, I'm easily convinced in this particular case.

OTOH, there are plenty of times when it's simply easier, quicker, and 
clearer to just implement trivial functionality in the JSP.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by Lukasz Lenart <lu...@googlemail.com>.
2009/4/21 Dave Newton <ne...@yahoo.com>:
> Meh--for simple stuff like this I'm not as sure, although if we're talking
> about a line item in a invoice, it wouldn't take much to convince me.

How do you want to test it? I know it's a simple case, but it's better
to have logic in one place.

> The issue for me would be that if this is money maths it should be using
> BigDecimal (or something), and I'm not sure what OGNL would do with the '*'
> operator.

So you answer your question, use additional method with no cost, with
easy way to extend the logic behind in the method.


Regards
-- 
Lukasz
http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Jasper Plugin cannot find file

Posted by Security Management <li...@secmgmt.com>.
OK, I took a smart pill, and put the following in my action:

JasperCompileManager.compileReportToFile(
 
this.getServletContext().getRealPath("/jasper/scrounger_report.jrxml"),
 
this.getServletContext().getRealPath("/jasper/scrounger_report.jasper"));

I'm logging that location with log4j, and will have to figure out how to put
it in the struts.xml file for the action.

Thanks for all the help.

-----Original Message-----
From: Balwinder Kumar [mailto:balwinder.mca@gmail.com] 
Sent: Tuesday, April 21, 2009 10:51 PM
To: Struts Users Mailing List
Subject: Re: Jasper Plugin cannot find file

I would suggest that first give the complete absolute path and check if 
the program is working fine, just to ensure, there is a problem with 
path only.

Once established problem is with path only, I may help you further.

Regards,
Balwinder Kumar

Security Management wrote:
> I'm using the tutorial here:
> http://struts.apache.org/2.0.14/docs/jasperreports-tutorial.html
>
> I have put a file here:
>
> /jasper/report.jrxml
>
> I can look in my war file and verify it.
>
> I'm trying to compile and render with it.  Here is my action code:
>
> <action name="saveReport" class="com.secmgmt.struts2.actions.SaveReport">
> 		<result name="success" type="jasper">
>             <param name="location">/jasper/scrounger_report.jasper</param>
>             <param name="dataSource">personList</param>
>             <param name="format">PDF</param>
>         </result>
> </action>
>
> I've also tried:
> <param name="location">my-webapp/jasper/scrounger_report.jasper</param>
>
> Which is what the tutorial has.
>
> In my action, I have:
> try
>             {
>                 JasperCompileManager.compileReportToFile(
>                     "my-webapp/jasper/scrounger_report.jrxml",
>                     "my-webapp/jasper/scrounger_report.jasper");
>             }
>             catch (Exception e)
>             {
>                 e.printStackTrace();
>                 return ERROR;
>             }
>
> But I always get a file not found error, I've tried just the
> /jasper/...jrxml too, without the appname (which I think is the correct
way)
> but no luck.
>
> What path should I be using if the file is in
/jasper/scrounger_report.jrxml
> in my war file?
>
> Thanks
> -----Original Message-----
> From: stanlick@gmail.com [mailto:stanlick@gmail.com] 
> Sent: Tuesday, April 21, 2009 2:29 PM
> To: Struts Users Mailing List
> Subject: Re: How to do matematical operation in jsp.
>
> Nice reference Wes!  BTW, I noticed you are not using the new cover letter
> for the TPS reports, so I'm going to have to go ahead and ask you to read
> that memo one more time.
>
> Peace,
> the Bob's
>
> On Tue, Apr 21, 2009 at 11:11 AM, Wes Wannemacher <we...@wantii.com> wrote:
>
>   
>> [snip]
>>     
>>> OTOH, siphoning the $.0000000000000039079850466805510222911834716796875
>>>       
>> into
>>     
>>> offshore accounts will eventually make you rich.
>>>
>>> Dave "Expecting his 10% cut" Newton
>>>
>>>       
>> [/snip]
>>
>> But, you have to be careful when moving the money into your own
account...
>>
>> [quote]
>> We're not just talking about while-collar, resort prison, we're
>> talking Federal Pound Me In the *** Prison!
>> [/quote]
>>
>> You have to be especially careful of mundane details like decimal places.
>>
>> -Wes
>>
>> --
>> Wes Wannemacher
>> Author - Struts 2 In Practice
>> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
>> http://www.manning.com/wannemacher
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>     
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Jasper Plugin cannot find file

Posted by Balwinder Kumar <ba...@gmail.com>.
I would suggest that first give the complete absolute path and check if 
the program is working fine, just to ensure, there is a problem with 
path only.

Once established problem is with path only, I may help you further.

Regards,
Balwinder Kumar

Security Management wrote:
> I'm using the tutorial here:
> http://struts.apache.org/2.0.14/docs/jasperreports-tutorial.html
>
> I have put a file here:
>
> /jasper/report.jrxml
>
> I can look in my war file and verify it.
>
> I'm trying to compile and render with it.  Here is my action code:
>
> <action name="saveReport" class="com.secmgmt.struts2.actions.SaveReport">
> 		<result name="success" type="jasper">
>             <param name="location">/jasper/scrounger_report.jasper</param>
>             <param name="dataSource">personList</param>
>             <param name="format">PDF</param>
>         </result>
> </action>
>
> I've also tried:
> <param name="location">my-webapp/jasper/scrounger_report.jasper</param>
>
> Which is what the tutorial has.
>
> In my action, I have:
> try
>             {
>                 JasperCompileManager.compileReportToFile(
>                     "my-webapp/jasper/scrounger_report.jrxml",
>                     "my-webapp/jasper/scrounger_report.jasper");
>             }
>             catch (Exception e)
>             {
>                 e.printStackTrace();
>                 return ERROR;
>             }
>
> But I always get a file not found error, I've tried just the
> /jasper/...jrxml too, without the appname (which I think is the correct way)
> but no luck.
>
> What path should I be using if the file is in /jasper/scrounger_report.jrxml
> in my war file?
>
> Thanks
> -----Original Message-----
> From: stanlick@gmail.com [mailto:stanlick@gmail.com] 
> Sent: Tuesday, April 21, 2009 2:29 PM
> To: Struts Users Mailing List
> Subject: Re: How to do matematical operation in jsp.
>
> Nice reference Wes!  BTW, I noticed you are not using the new cover letter
> for the TPS reports, so I'm going to have to go ahead and ask you to read
> that memo one more time.
>
> Peace,
> the Bob's
>
> On Tue, Apr 21, 2009 at 11:11 AM, Wes Wannemacher <we...@wantii.com> wrote:
>
>   
>> [snip]
>>     
>>> OTOH, siphoning the $.0000000000000039079850466805510222911834716796875
>>>       
>> into
>>     
>>> offshore accounts will eventually make you rich.
>>>
>>> Dave "Expecting his 10% cut" Newton
>>>
>>>       
>> [/snip]
>>
>> But, you have to be careful when moving the money into your own account...
>>
>> [quote]
>> We're not just talking about while-collar, resort prison, we're
>> talking Federal Pound Me In the *** Prison!
>> [/quote]
>>
>> You have to be especially careful of mundane details like decimal places.
>>
>> -Wes
>>
>> --
>> Wes Wannemacher
>> Author - Struts 2 In Practice
>> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
>> http://www.manning.com/wannemacher
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>     
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   


RE: Jasper Plugin cannot find file

Posted by Security Management <li...@secmgmt.com>.
Doh, I must have replied to a topic, my bad.

>>What is "my-webapp"? A directory? Your web app's context? If the latter, 
>>that certainly won't work, you'd need to get the path relative to your 
>>webapp's deployment.

Yes, it's the context directory, I've also just tried it with
/jasper/scrounger_report.jasper.

> I have put a file here:
> 
> /jasper/report.jrxml

>>Without any context I have no idea where that file is: is it on the 
>>classpath? Is it in the webapp root?

The webapp root, that is, if I do a listing of my war file, it's in the root
of it, at /jasper/scrounger_report.jasper

>>If compileReportToFile is expecting a physical file you may have issues 
>>if you're deploying a war file, since files contained in it may not be 
>>accessible in this manner.

I've looked in my webapps directory, the war gets expanded and the file
exists on the filesystem.  Are you saying I may still have issues?

>>Are you actually compiling the report each time the action is hit?

No, I'm just testing to make sure I can figure this out.


-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Tuesday, April 21, 2009 4:37 PM
To: Struts Users Mailing List
Subject: Re: Jasper Plugin cannot find file

Please start new threads for new topics.

Security Management wrote:
> I have put a file here:
> 
> /jasper/report.jrxml

Without any context I have no idea where that file is: is it on the 
classpath? Is it in the webapp root?

> <action name="saveReport" class="com.secmgmt.struts2.actions.SaveReport">
> 		<result name="success" type="jasper">
>             <param name="location">/jasper/scrounger_report.jasper</param>
>             <param name="dataSource">personList</param>
>             <param name="format">PDF</param>
>         </result>
> </action>
> 
> I've also tried:
> <param name="location">my-webapp/jasper/scrounger_report.jasper</param>
> 
> Which is what the tutorial has.
> 
> In my action, I have:
> try
>             {
>                 JasperCompileManager.compileReportToFile(
>                     "my-webapp/jasper/scrounger_report.jrxml",
>                     "my-webapp/jasper/scrounger_report.jasper");

What is "my-webapp"? A directory? Your web app's context? If the latter, 
that certainly won't work, you'd need to get the path relative to your 
webapp's deployment.

If compileReportToFile is expecting a physical file you may have issues 
if you're deploying a war file, since files contained in it may not be 
accessible in this manner.

Are you actually compiling the report each time the action is hit?

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Jasper Plugin cannot find file

Posted by Dave Newton <ne...@yahoo.com>.
Please start new threads for new topics.

Security Management wrote:
> I have put a file here:
> 
> /jasper/report.jrxml

Without any context I have no idea where that file is: is it on the 
classpath? Is it in the webapp root?

> <action name="saveReport" class="com.secmgmt.struts2.actions.SaveReport">
> 		<result name="success" type="jasper">
>             <param name="location">/jasper/scrounger_report.jasper</param>
>             <param name="dataSource">personList</param>
>             <param name="format">PDF</param>
>         </result>
> </action>
> 
> I've also tried:
> <param name="location">my-webapp/jasper/scrounger_report.jasper</param>
> 
> Which is what the tutorial has.
> 
> In my action, I have:
> try
>             {
>                 JasperCompileManager.compileReportToFile(
>                     "my-webapp/jasper/scrounger_report.jrxml",
>                     "my-webapp/jasper/scrounger_report.jasper");

What is "my-webapp"? A directory? Your web app's context? If the latter, 
that certainly won't work, you'd need to get the path relative to your 
webapp's deployment.

If compileReportToFile is expecting a physical file you may have issues 
if you're deploying a war file, since files contained in it may not be 
accessible in this manner.

Are you actually compiling the report each time the action is hit?

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Jasper Plugin cannot find file

Posted by Security Management <li...@secmgmt.com>.
I'm using the tutorial here:
http://struts.apache.org/2.0.14/docs/jasperreports-tutorial.html

I have put a file here:

/jasper/report.jrxml

I can look in my war file and verify it.

I'm trying to compile and render with it.  Here is my action code:

<action name="saveReport" class="com.secmgmt.struts2.actions.SaveReport">
		<result name="success" type="jasper">
            <param name="location">/jasper/scrounger_report.jasper</param>
            <param name="dataSource">personList</param>
            <param name="format">PDF</param>
        </result>
</action>

I've also tried:
<param name="location">my-webapp/jasper/scrounger_report.jasper</param>

Which is what the tutorial has.

In my action, I have:
try
            {
                JasperCompileManager.compileReportToFile(
                    "my-webapp/jasper/scrounger_report.jrxml",
                    "my-webapp/jasper/scrounger_report.jasper");
            }
            catch (Exception e)
            {
                e.printStackTrace();
                return ERROR;
            }

But I always get a file not found error, I've tried just the
/jasper/...jrxml too, without the appname (which I think is the correct way)
but no luck.

What path should I be using if the file is in /jasper/scrounger_report.jrxml
in my war file?

Thanks
-----Original Message-----
From: stanlick@gmail.com [mailto:stanlick@gmail.com] 
Sent: Tuesday, April 21, 2009 2:29 PM
To: Struts Users Mailing List
Subject: Re: How to do matematical operation in jsp.

Nice reference Wes!  BTW, I noticed you are not using the new cover letter
for the TPS reports, so I'm going to have to go ahead and ask you to read
that memo one more time.

Peace,
the Bob's

On Tue, Apr 21, 2009 at 11:11 AM, Wes Wannemacher <we...@wantii.com> wrote:

> [snip]
> >
> > OTOH, siphoning the $.0000000000000039079850466805510222911834716796875
> into
> > offshore accounts will eventually make you rich.
> >
> > Dave "Expecting his 10% cut" Newton
> >
> [/snip]
>
> But, you have to be careful when moving the money into your own account...
>
> [quote]
> We're not just talking about while-collar, resort prison, we're
> talking Federal Pound Me In the *** Prison!
> [/quote]
>
> You have to be especially careful of mundane details like decimal places.
>
> -Wes
>
> --
> Wes Wannemacher
> Author - Struts 2 In Practice
> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> http://www.manning.com/wannemacher
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by Andy Sykes <a....@ucl.ac.uk>.
Abstract the HashMap behind another class that has a getTotal(Item  
key) method, and do the math in there (return item.prize * quantity).

Doing any math in the JSP feels dirty.

On 22 Apr 2009, at 13:16, Stefano Tranquillini wrote:

> Because the items are stored in hashmap <Item, Quantity> item  
> contains the
> prize.
> so, to know the total for each item i've to multplay item.prize with
> quantity.
>
> no more else.
>
>
>
> On Wed, Apr 22, 2009 at 14:01, Dave Newton <ne...@yahoo.com>  
> wrote:
>
>> Stefano Tranquillini wrote:
>>
>>> but i've only to display in a jsp the results, when i use that  
>>> value i
>>> compute it by the ejb.
>>>
>>
>> Then why are you re-computing it in the JSP?
>>
>> The point is only that floating-point math is inaccurate. If you  
>> don't
>> care, or are controlling the results of the math somehow, then fine.
>>
>>
>> Dave
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> -- 
> Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by Stefano Tranquillini <st...@gmail.com>.
Because the items are stored in hashmap <Item, Quantity> item contains the
prize.
so, to know the total for each item i've to multplay item.prize with
quantity.

no more else.



On Wed, Apr 22, 2009 at 14:01, Dave Newton <ne...@yahoo.com> wrote:

> Stefano Tranquillini wrote:
>
>> but i've only to display in a jsp the results, when i use that value i
>> compute it by the ejb.
>>
>
> Then why are you re-computing it in the JSP?
>
> The point is only that floating-point math is inaccurate. If you don't
> care, or are controlling the results of the math somehow, then fine.
>
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Stefano

Re: How to do matematical operation in jsp.

Posted by Dave Newton <ne...@yahoo.com>.
Stefano Tranquillini wrote:
> but i've only to display in a jsp the results, when i use that value i
> compute it by the ejb.

Then why are you re-computing it in the JSP?

The point is only that floating-point math is inaccurate. If you don't 
care, or are controlling the results of the math somehow, then fine.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by Stefano Tranquillini <st...@gmail.com>.
but i've only to display in a jsp the results, when i use that value i
compute it by the ejb.

On Tue, Apr 21, 2009 at 22:51, Dave Newton <ne...@yahoo.com> wrote:

> Stefano Tranquillini wrote:
>
>> The right solution is to calculate and insert in a new bean the elements
>> and
>> its total value?
>>
>
> That's *a* right solution, yes, particularly since you're doing money math.
> For money math to produce consistent, correct results you usually need to
> define a precision and rounding mechanism, since floating point math is
> inherently inaccurate.
>
> Dave
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Stefano

Re: How to do matematical operation in jsp.

Posted by Dave Newton <ne...@yahoo.com>.
Stefano Tranquillini wrote:
> The right solution is to calculate and insert in a new bean the elements and
> its total value?

That's *a* right solution, yes, particularly since you're doing money 
math. For money math to produce consistent, correct results you usually 
need to define a precision and rounding mechanism, since floating point 
math is inherently inaccurate.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by Stefano Tranquillini <st...@gmail.com>.
The right solution is to calculate and insert in a new bean the elements and
its total value?

On Tue, Apr 21, 2009 at 20:29, <st...@gmail.com> wrote:

> Nice reference Wes!  BTW, I noticed you are not using the new cover letter
> for the TPS reports, so I'm going to have to go ahead and ask you to read
> that memo one more time.
>
> Peace,
> the Bob's
>
> On Tue, Apr 21, 2009 at 11:11 AM, Wes Wannemacher <we...@wantii.com> wrote:
>
> > [snip]
> > >
> > > OTOH, siphoning the $.0000000000000039079850466805510222911834716796875
> > into
> > > offshore accounts will eventually make you rich.
> > >
> > > Dave "Expecting his 10% cut" Newton
> > >
> > [/snip]
> >
> > But, you have to be careful when moving the money into your own
> account...
> >
> > [quote]
> > We're not just talking about while-collar, resort prison, we're
> > talking Federal Pound Me In the *** Prison!
> > [/quote]
> >
> > You have to be especially careful of mundane details like decimal places.
> >
> > -Wes
> >
> > --
> > Wes Wannemacher
> > Author - Struts 2 In Practice
> > Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> > http://www.manning.com/wannemacher
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>



-- 
Stefano

Re: How to do matematical operation in jsp.

Posted by st...@gmail.com.
Nice reference Wes!  BTW, I noticed you are not using the new cover letter
for the TPS reports, so I'm going to have to go ahead and ask you to read
that memo one more time.

Peace,
the Bob's

On Tue, Apr 21, 2009 at 11:11 AM, Wes Wannemacher <we...@wantii.com> wrote:

> [snip]
> >
> > OTOH, siphoning the $.0000000000000039079850466805510222911834716796875
> into
> > offshore accounts will eventually make you rich.
> >
> > Dave "Expecting his 10% cut" Newton
> >
> [/snip]
>
> But, you have to be careful when moving the money into your own account...
>
> [quote]
> We're not just talking about while-collar, resort prison, we're
> talking Federal Pound Me In the *** Prison!
> [/quote]
>
> You have to be especially careful of mundane details like decimal places.
>
> -Wes
>
> --
> Wes Wannemacher
> Author - Struts 2 In Practice
> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> http://www.manning.com/wannemacher
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: How to do matematical operation in jsp.

Posted by Wes Wannemacher <we...@wantii.com>.
[snip]
>
> OTOH, siphoning the $.0000000000000039079850466805510222911834716796875 into
> offshore accounts will eventually make you rich.
>
> Dave "Expecting his 10% cut" Newton
>
[/snip]

But, you have to be careful when moving the money into your own account...

[quote]
We're not just talking about while-collar, resort prison, we're
talking Federal Pound Me In the *** Prison!
[/quote]

You have to be especially careful of mundane details like decimal places.

-Wes

-- 
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by Dave Newton <ne...@yahoo.com>.
Jim Kiley wrote:
> RoundingMode.SUPERMAN_III

I've caffeinated my nose.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by Jim Kiley <jh...@summa-tech.com>.
RoundingMode.SUPERMAN_III
On Tue, Apr 21, 2009 at 12:07 PM, Dave Newton <ne...@yahoo.com> wrote:

> Dave Newton wrote:
>
>> The issue for me would be that if this is money maths it should be using
>> BigDecimal (or something), and I'm not sure what OGNL would do with the '*'
>> operator.
>>
>
> It would multiply the BigDecimals, but using a default MathContext, which
> may or may not give the results you really want.
>
> OTOH, siphoning the $.0000000000000039079850466805510222911834716796875
> into offshore accounts will eventually make you rich.
>
> Dave "Expecting his 10% cut" Newton
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Jim Kiley
Senior Technical Consultant | Summa
[p] 412.258.3346
http://www.summa-tech.com

Re: How to do matematical operation in jsp.

Posted by Dave Newton <ne...@yahoo.com>.
Dave Newton wrote:
> The issue for me would be that if this is money maths it should be using 
> BigDecimal (or something), and I'm not sure what OGNL would do with the 
> '*' operator.

It would multiply the BigDecimals, but using a default MathContext, 
which may or may not give the results you really want.

OTOH, siphoning the $.0000000000000039079850466805510222911834716796875 
into offshore accounts will eventually make you rich.

Dave "Expecting his 10% cut" Newton



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by Dave Newton <ne...@yahoo.com>.
Lukasz Lenart wrote:
> 2009/4/21 Stefano Tranquillini <st...@gmail.com>:
>> how can i do that?
> 
> Add method to class Item to do that, jsp isn't place for business logic

Meh--for simple stuff like this I'm not as sure, although if we're 
talking about a line item in a invoice, it wouldn't take much to 
convince me.

The issue for me would be that if this is money maths it should be using 
BigDecimal (or something), and I'm not sure what OGNL would do with the 
'*' operator.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to do matematical operation in jsp.

Posted by Lukasz Lenart <lu...@googlemail.com>.
2009/4/21 Stefano Tranquillini <st...@gmail.com>:
> how can i do that?

Add method to class Item to do that, jsp isn't place for business logic


Regards
-- 
Lukasz
http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org