If the lookup is within the component namespace (java:comp/env) then all entries are fixed at deployment time. You can dynamically construct the string that is passed to the lookup method, but it would have to match one of the pre-configured entries in the component environment.
If you bypass the component environment and do a global lookup, you'll be able to see whatever is is defined at the time of the lookup. The downside is the names themselves are not portable. Plus, it won't be guaranteed to work for some resources such as the Local interfaces of EJB components.
[Message sent by forum member 'ksak' (ksak)]
http://forums.java.net/jive/thread.jspa?messageID=275479