views:

9

answers:

1

I have to store the one String object at the application level and have to access it in the JSP page. How to do this?Please give me some sample.

A: 

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

Isaac