How to store value which is sharable at the application level in struts1 like session?
I have to store the one String object at the application l开发者_如何学运维evel and have to access it in the JSP page. How to do this?Please give me some sample.
The ServletContext.setAttribute(key, value)
can be used to store an object under a particular key, at the application level.
To access it from JSP, it really depends how you're accessing it. The easiest way is to do it via EL, so if your key was mykey
, the expression ${mykey}
should return the String that you stored.
Additional example: http://www.coderanch.com/t/293528/JSP/java/servletcontext-attribute-jsp
精彩评论