In my webapp, I must use the context.xml to register a variable which is to be used in a JSP. For example, a variable X with the value "xfromcontext", so that I can print it in JSP as out.println(X). How do I get the X‘s value from context.xml?
In my webapp, I must use the context.xml to register a variable which is
Share
You can specify an
<Environment>entry which does exactly the same as regular<env-entry>inweb.xml.E.g.
which is obtainable (in servlet) by
I’d suggest to read it once and store it in the application scope on webapp’s startup. You can use a
ServletContextListenerfor this. Then you can just access it in JSP by${X}. Doing aout.println()in JSP is a rather old school way which has been discouraged over a decade ago.