• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsp:getProperty problem

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use java code straight in the JSP
<%= gt.getValues() + bt.getValues() + mt.getValues() %>
 
mudassir shahab
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 am mighty! And this is a mighty small ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic