Forums Register Login
Mock exam question about Context and environment entry
Hi, I've got the following question:

Given a bean named 'Customer', and an environment entry named 'lastName', which code fragment(s) inside of the bean class would return the value of the environment entry?

Answers (here for brevity I put only 2 of the five)



I said one, but correct was 2. Why?
Actually, all environment entries are stored directly in the "java:comp/env" context or a subcontext thereof. If you see something like


it means that the deployment descriptor has to look like


Bottom line: The bean name must no be included in the context name because each bean has its own private context anyway. This means that two different beans each have their own "java:comp/env" context. Moreover, if there are subcontexts, they are specified in the deployment descriptor by means of a /-separated sequence of characters.
[ July 27, 2004: Message edited by: Valentin Crettaz ]
Originally posted by Valentin Crettaz:

Thank you. That was clear!

Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

All times above are in ranch (not your local) time.
The current ranch time is
Dec 16, 2017 15:40:36.