As this is a struts list then perhaps you'd consider using a struts action or even perhaps a plain old servlet to do what you need.


request.setAttribute("test",MyClass.TEST);

if its a map then

request.setAttribute("mymap",map);

or even

Iterator keys = map.keySet().iterator();

while(keys.hasNext()) {
        String key = keys.next().toString();
        request.setAttribute(key,map.get(key));
}

...

this way you can access your properties in you page as follows

<c:out value="${mykey}" />

which will return the value of the given key.

also

<jsp:useBean id="yourbean" class="com.yourdomain.yourpackage.YourClass" scope="request" />

<c:out value="${yourbean.yourproperty}" />

And thus save all that importing in jsp..

HTH

Mark


On 22 Sep 2004, at 11:42, andy wix wrote:

Hi,

I am a little surprised that having a class variable imported into a page isn't seen by JSTL contructs.
For example if i have a class that defines:


package com.company.test
public final class MyClass
{
  public static final String TEST =  "test";
}

and my JSP page has:

<[EMAIL PROTECTED] import="com.company.test.MyClass"%>
<c:out value="${MyClass.TEST}"/>

you don't get any output.

If you add:
<%
pageContext.setAttribute("test", MyClass.TEST);
%>

and change the JSTL to:
<c:out value="${test}"/>

then it works.

But surely the MyClass.TEST already had page scope otherwise the setAttribute wouldn't have seen it?

The upshot of all this is that I am iterating through a map that can have any one of about 30 keys.
Do I really have to put all these keys into the session or some other scope every time I load the page?


Thanks,
Andy

_________________________________________________________________
Stay in touch with absent friends - get MSN Messenger http://www.msn.co.uk/messenger



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to