File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes How to use Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to use "jsp:getproperty" within html "style" tag?" Watch "How to use "jsp:getproperty" within html "style" tag?" New topic
Author

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

smee bond
Ranch Hand

Joined: Sep 29, 2007
Posts: 34
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

Joined: Jan 10, 2002
Posts: 61095
    
  66

Why would you use either of scriptlets or getProperty in place of the EL?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
smee bond
Ranch Hand

Joined: Sep 29, 2007
Posts: 34
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

Joined: Jan 10, 2002
Posts: 61095
    
  66

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

Joined: Sep 29, 2007
Posts: 34
I am using JSP 2.0. Thank you for your suggestion. I used EL and it works perfectly fine.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use "jsp:getproperty" within html "style" tag?