• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use "jsp:getproperty" within html "style" tag?

 
smee bond
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have the following code in my jsp file:
<style>
#subject,
#message,
#delivery {
border-left: 1px solid #999;
border-right: 1px solid #999;
border-bottom: 1px solid #999;
padding: 10px 10px;
background: #fff url('<%=request.getContextPath()%>/gradientServlet?height=50&color1=ffffff&color2=<%=color%>')bottom repeat-x;
}
</style>
In place of <%=color%>, how do I use <jsp:getProperty name="UtilBean" property="color" /> tag?
[ December 01, 2007: Message edited by: smee bond ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you use either of scriptlets or getProperty in place of the EL?
 
smee bond
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to get the value for "color" dynamically. Earlier the jsp page had a huge scriptlet that was doing the job. Now I have moved the scriptlet to a bean class and want to get the value for "color" from the bean. Is there a better way I can do this?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of JSP are you using?

If it's JSP 2.0 you should be advancing to the use of the EL in favor of scriptlets and the older JSP actions.

With the EL, let's say that you place the bean in request scope with the name myBean. Referencing its color property would be:
[ December 01, 2007: Message edited by: Bear Bibeault ]
 
smee bond
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using JSP 2.0. Thank you for your suggestion. I used EL and it works perfectly fine.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic