STRUTS JSP question; trying to use application.resource value inside logic tag for value param; is this possible?

Posted on 2004-11-23
Last Modified: 2010-04-01

Hi all. I am attempting to do the following:

<logic:greaterThan name="RecordCount" property="errCode" value="<bean:message key='anumbervalue' />" >
      <bean:message key="amessagetodsiplay" />

Pretty much I need a message to be displayed depending on the number of records returned from a query. This min # of records that must be retreived to receive this message is stored in my file. I am trying to use this value as the value to be compared to in the logic:greaterThan operation.
The actual names of the keys have been changed for privacy reasons.

I have tried displayed the messages by themselves and that works fine so retrieving the values these keys is not the issue. The above code also works if I hard code the value inisde the value attribute, but that just sends a shiver down my spine.

Any ideas are welcome. Need any and all thoughts ASAP. Thanks a bunch. Later.
Question by:jbaisden
    LVL 8

    Accepted Solution

    try this..

        <bean:define id="theNumber" value="<bean:message key='anumbervalue' />"/>

    <logic:greaterThan name="RecordCount" property="errCode" value="<%= theNumber %>"

    Author Comment

    I'll give it a try but I really can't use the <% ... %> tags.

    Expert Comment

    Because Struts is built on top of JSP/Servet technoloy, you can always fallback on the use of JSP tags. So using <%=.....%> can't be the problem.
    LVL 14

    Expert Comment

    Not sure why you cant use <%...%>, but if you really dont want to use scriptlet,
    then you might consider using JSTL tag.
    LVL 1

    Expert Comment

    You cannot use Struts tag inside another Struts tag. In this example: the "value" parameter which you pass to the "logic:greaterThan" has to be a constant value or a scriptlet - but it cannot be equation that you'll get by evaluating another Struts tag. In other words, you'll have to use scriptlet inside the "value" parameter. It can be as simple as "<%= anumber %>", but first you'll have to declare this variable:

    <bean:define id="anumber">
      <bean:message key="anumbervalue" />

    Author Comment

    To clarify the decision not to use the <% %> is part of a standard decided on by the development team in an effort to use as little programming in the presentation layer as possible. This is not the cause of an error or anything of that sort. However, I see that we can not do what I am asking unless we use the <% %> so I will recommend an exception. One infinitesimal addition of programming to the presentation layer in exchange for immediate dynamic response seems a fair trade, but the worry is falling into this habit over and over and before long the presentation layer is obscured by programming logic. Blah. I'm preaching to the choir. Do you guys think this is going over board or would you say I am somewhat justified in this approach?
    LVL 29

    Expert Comment

    Use JSTL
    <c:if test='${sessionScope.javaBean.myValue > param.RecordCount}'>
         <!-- Your meessage -->
    LVL 8

    Expert Comment

    can you close this question... its been more than 3 months...........

    Author Comment

    Sorry that I hadn't closed this thread yet. Thanks for your help guys.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    If you're not part of the solution, you're part of the problem.   Tips on how to secure IoT devices, even the dumbest ones, so they can't be used as part of a DDoS botnet.  Use PRTG Network Monitor as one of the building blocks, to detect unusual…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now