You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Justin Ashworth <ju...@ashworth.org> on 2003/01/06 23:00:29 UTC
Accessing static constants with EL
Hope you're all doing well in the new year.
I am just starting to use EL syntax so this question may be very basic. I
have an interface which contains many public static final variables that I
would like to be able to access with the EL tags. For regular tags that
support rtexprvalues, I would just use <html:option
value="<%=Constant.MY_VALUE%>">. How can this be done with the EL tags,
keeping in mind that this is an interface and not a class?
I have tried several different methods. First I tried <html-el:option
value="${Constant.MY_VALUE}"> to no avail. Then I did this: <jsp:useBean
id="con" class="c.d.u.w.ConstantImpl" /> and <html-el:option
value="${con.MY_VALUE}">, which also didn't work.
What am I missing?
Thanks,
Justin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Tracking sessions (newbie)
Posted by Loren Hall <lo...@attbi.com>.
I seem to have colliding sessions, I figure as a result of improperly using
jsessionids. Was I wrong to think that struts and tomcat handled this
transparently?
Current Situation:
The appearance of jsessionid= in urls is erratic, appending the jsessionid
to the inital login url one minute, but not the next.
It's appended to both the page url and to a <html:link within the
welcome.jsp (post-login) page in the case of login . . .
But, in the case of new registrations, it's appended to the url, but not the
<html:link . . . then seconds later this behavior reverses.
The lack of consistency makes understanding the problem difficult, and I can
find virtually no "how-to-use" type documentation. Can anybody point me to
a tutorial to step through this, or can anyone point out where I am likely
losing (not resetting) the session information.
Any thoughts as to how this problem arose, or how to attack this problem are
greatly appreciated. Right now, if the admin logs in on one browser, when
an end-user has an active session, the end-user will end up with the admin's
session (and functionality) . . . arggh
Loren
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Accessing static constants with EL
Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "Justin" == Justin Ashworth <ju...@ashworth.org> writes:
Justin> Hope you're all doing well in the new year.
Justin> I am just starting to use EL syntax so this question may be very basic. I
Justin> have an interface which contains many public static final variables that I
Justin> would like to be able to access with the EL tags. For regular tags that
Justin> support rtexprvalues, I would just use <html:option
Justin> value="<%=Constant.MY_VALUE%>">. How can this be done with the EL tags,
Justin> keeping in mind that this is an interface and not a class?
Justin> I have tried several different methods. First I tried <html-el:option
Justin> value="${Constant.MY_VALUE}"> to no avail. Then I did this: <jsp:useBean
Justin> id="con" class="c.d.u.w.ConstantImpl" /> and <html-el:option
Justin> value="${con.MY_VALUE}">, which also didn't work.
Justin> What am I missing?
You should read the JSTL specification to get a clear idea of what you can do
with EL expressions.
In particular, you can only reference javabean properties, map entries, or
collection/array entries.
This particular question has come up more than once. That is, the idea of
referencing constant values from an interface in EL expressions. There is one
sort of bizarre thing you could do to facilitate this without much, if any,
hardcoding.
The fact that the EL can reference map entries provides for the possibility of
having an object that is initialized with a class, which uses reflection to get
a list of all of the "static final" fields of the class, and puts all the
attribute names and values into a hashmap, with the attribute names as keys.
The gnarly reflection and map loading would just happen once.
When the EL references map entries, it can look exactly like normal javabean
references. If you're determined to reference these constants in EL
expressions, this may be the cleanest way to get this done.
--
===================================================================
David M. Karr ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net ; SCJP; SCWCD
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>