Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 151
  • Last Modified:

Playing "Data" with get and set property

See this,

JSP pages
=========
<! String test="":
%>
...
...
<jsp:getProperty name="a" property="name" />



Actually i want the return value of this property (name) to be set as a test (variable in my jsp pages).

how can i do that?
0
poweranger77
Asked:
poweranger77
  • 5
  • 3
1 Solution
 
poweranger77Author Commented:
For example, I can do this,

<jsp:setProperty name="upt" property="billcode" param="<jsp:getProperty name="debit1" property="billcode" />" />

But yet, it's thrown mw error... Bur is this a correct one?
or this should be the one,

<jsp:setProperty name="upt" property="billcode" value="<jsp:getProperty name="debit1" property="billcode" />" />
0
 
kennethxuCommented:
>> Actually i want the return value of this property (name) to be set as a test (variable in my jsp pages).
you need this:
<jsp:getProperty name="a" property="name" value='<%=test%>' />

>> <jsp:setProperty name="upt" property="billcode" param="<jsp:getProperty name="debit1" property="billcode" />" />
>> <jsp:setProperty name="upt" property="billcode" value="<jsp:getProperty name="debit1" property="billcode" />" />
neither is not correct, you cannot use a tag as another tag's attribute value.
0
 
kennethxuCommented:
you need this:
<jsp:setProperty name="upt" property="billcode" value="<%=debit1.getBillcode()%>" />" />
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
poweranger77Author Commented:
>>you need this:
<jsp:getProperty name="a" property="name" value='<%=test%>' />

This one seems doesn't work for me.

I want to set a variable that whole the return valur when I getProperty from a bean.

..
..
<! String number="": %>
..
..
Receipt : <jsp:getProperty name="a" property="name" value="<%= number %>" />
..
..
out.println("Number " + number );



I should see
Receipt : ABC12345
Number  : ABC12345
right?

But he thrown me error...

saying
com.sum.jsp.JspException :"getProperty: Invalid atribute, value"

Meaning to say that I can't put in value into getProperty tag right?
0
 
kennethxuCommented:
sorry, misunderstood the first part of your question:

you can just simply use <% number=a.getName() %>. you cannot assign to a script var by using <jsp:getProperty> tag.
0
 
poweranger77Author Commented:
TQ...

I think that's the weakness of the JSP syntax. If I am going touse your suggestion, end up my JSP will back to Servlets prevoius problem, all mixed up with HTML tag, javaCode and also JSP tag....

ai......

Anyway, thanks for your time.
0
 
kennethxuCommented:
>> end up my JSP will back to Servlets prevoius problem, all mixed up with HTML tag, javaCode and also JSP tag....
struts has a set of bean tags can do what you are looking for.

struts: http://jakarta.apache.org/struts/doc-1.0.2/index.html

its bean taglib: http://jakarta.apache.org/struts/doc-1.0.2/api/org/apache/struts/taglib/bean/package-summary.html#package_description
0
 
kennethxuCommented:
>> all mixed up with HTML tag, javaCode and also JSP tag....

if you hate this, then you should seriously consider MVC design with struts framework.

HTH
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now