• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to assign bean value to jsp variable

 
Praveen palukuri
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I've a doubt that how can i assign a bean value to jsp variable. i'd tried the below code:

<% String status = "<bean:write name='usersearch' property='userStatus'/>"; %>

But it's giving an error. If any one knows please help me.

Regards,
Praveen.
 
Zhang Alan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Praveen palukuri:
hi,
I've a doubt that how can i assign a bean value to jsp variable. i'd tried the below code:

<% String status = "<bean:write name='usersearch' property='userStatus'/>"; %>

But it's giving an error. If any one knows please help me.

Regards,
Praveen.



Hi.

I think you can do it like this:

<bean: define id="status" name="usersearch" property="userStatus"/>

The space between "bean:" and "define" is written because ":" and "d" is change to when there isn't a space...
[ November 10, 2005: Message edited by: Zhang Alan ]
 
Manuel Sanchez Iba�ez
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, i have a similar problem. I use a session object for display information in ArrayList. Each element in ArrayList is a class like:

private String nombre;
private int tiempofila;


I need divide one number between "tiempofila" but i only can show this value. I can recover and show this value in 3 ways:

<logic resent name="tabladatos">

<logic:iterate id="inf2" name="tabladatos">

<bean efine id="por2" name="inf2" property="tiempofila"/>
<bean:write name="por2"/>%<br/>

<jsp:getProperty name="inf2" property="tiempofila"/>%<br/>

<bean:write name="inf2" property="tiempofila"/>%<br/>

---<br/>
</logic:iterate>
......

This code work fine but i don�t need show this value, i need work with it:

<%int value = <bean:write name="inf2" property="tiempofila"/> %>

My goal is calculate one percentaje:

<%int percentaje = 33 * 100 / value %>

�Is possible assign this?
 
vikhyath reddy
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its simple ...

<% String s=mybeanid.getProperty();

---- your code -----

%>
 
Andy Lileston
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could also do it very easily in JSTL
 
Raghava Chary
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<bean:define id="abc" name="FormName" property="Property" type="java.lang.String"/>
<%=abc%>>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic