This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes jsp:getProperty problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp:getProperty problem" Watch "jsp:getProperty problem" New topic
Author

jsp:getProperty problem

mudassir shahab
Ranch Hand

Joined: Oct 13, 2003
Posts: 54
hi friends...
i have a problem regarding jsp:getProperty...look at the code
<jsp:getProperty name="gt" property="values" />
<jsp:getProperty name="bt" property="values" />
<jsp:getProperty name="mt" property="values" />
these three tags are returning integer values ..i want add three of them
and display the sum in a jsp file..how can i do this
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
use java code straight in the JSP
<%= gt.getValues() + bt.getValues() + mt.getValues() %>


Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
mudassir shahab
Ranch Hand

Joined: Oct 13, 2003
Posts: 54
thanks Tim....
but the problem exists..actually these bean tags are in three different jsp files ..and i want to add them in another jsp file..how will i do this....
thanks
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
if they are being use at the same time for the same page then set the scope of the been to be request.
mudassir shahab
Ranch Hand

Joined: Oct 13, 2003
Posts: 54
i have set the scope of the bean to request..but still no success..actually i am creating an online shopping cart...which has three departments..when user clicks check out i want to show the total of all the departments ...thanks
Anselm Paulinus
Ranch Hand

Joined: Sep 05, 2003
Posts: 389
What error is it giving you? The code Tim has on the should solve your problem. Copy and paste your code on the board along with the error and let us analyse them.
mudassir shahab
Ranch Hand

Joined: Oct 13, 2003
Posts: 54
error :
Undefined variable or class name: gt,bt, mt
out.print( gt.getValues() + bt.getValues() + mt.getValues() );
-------------------------
i am writng the statement <% =gt.getValues() + bt.getValues() + mt.getValues
%> in a jsp file...
------------------------------
where gt is the name of instance of a bean in another jsp file
<jsp:useBean id="gt" property ="value" param="name" />
like wise 'bt' and 'mt' are the names of instances of the same bean..
when i want to add them through the above statement i have written on the top it shows error(which is defined above)
Anselm Paulinus
Ranch Hand

Joined: Sep 05, 2003
Posts: 389
I am very surprise that <jsp:useBean id="gt" property ="value" param="name" /> passed translation phase. The code does not look correct to me.
<jsp:useBean.../> only takes the following attributes id, scope, class, type and beanName.
Your <jsp:useBean /> should be something like this <jsp:useBean id="gt" class="the jave class of the bean"/> Try this and lets see what happens
mudassir shahab
Ranch Hand

Joined: Oct 13, 2003
Posts: 54
yes u r rite..i have written the wrong code ..but in actual i have implemented the rite one..the problem is let me know how can i access three different bean values returning integer through getproperty tag in another jsp file ...go through the code rite from the first msg..
Anselm Paulinus
Ranch Hand

Joined: Sep 05, 2003
Posts: 389
I went through the codes from the first post and I think Tim gave you a working solution; which is to set the beans in the request and access them using <%= gt.getValues() + bt.getValues() + mt.getValues() %>. Make sure that you have the <jsp:useBean .../> declared before trying to access them. Also make sure that they are in scope that is you do not have your <jsp:useBean .../> in a code block that limits their visibility to <%= gt.getValues() + bt.getValues() + mt.getValues() %>.
If this still do not work for you, then you might have to do it with raw java(scriptlets) codes instead of using taglib. Let us know how you eventually resolve this.
mudassir shahab
Ranch Hand

Joined: Oct 13, 2003
Posts: 54
sorry..the prob yet not solved....the game is simple..there are total four jsp classes ...three of them have the jspusebean tag to set the property of the same javabean with different id names bt , gt and mt ,returning int values through there getproperty tags..i want to add them in the fourth jsp file so there is no question of defining <jsp:useBean.../> in the fourth class..its just the matter of scope ...coz the error is that it is not resolving the name gt,mt or bt in fourth jsp file..plz reply
thanks for ur replies
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp:getProperty problem
 
Similar Threads
Clarification needed regarding jsp:getProperty
Can't pass changed beans values from one JSP page to another
jspuseBean error??
Creating a java bean in a servlet and accessing it in a jsp
problem with javaBean