Re: JSTL and scope
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 which will return the value of the given key. also 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"%> you don't get any output. If you add: <% pageContext.setAttribute("test", MyClass.TEST); %> and change the JSTL to: 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]
RE: JSTL and scope
I can see where you are coming from. I would also like to be able to call custom methods on objects rather than just those that have getXXX. I suppose this is all to do with JSTL adhering to strict bean specification with everything acquired by get methods matching class members. you would need a method called getTEST to be able to access using JSTL because doing MyClass.TEST with JSTL violates the bean spec. > -Original Message- > From: andy wix [mailto:[EMAIL PROTECTED] > Sent: 22 September 2004 10:42 > To: [EMAIL PROTECTED] > Subject: JSTL and scope > > > 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"%> > > > you don't get any output. > > If you add: > <% > pageContext.setAttribute("test", MyClass.TEST); > %> > > and change the JSTL to: > > > 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] > > --- QAS Ltd. Developers of QuickAddress Software http://www.qas.com";>www.qas.com Registered in England: No 2582055 Registered in Australia: No 082 851 474 --- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]