Jump to content

Constants?


davej
 Share

Recommended Posts

If you have several JSP pages or servlets that need the same bit of information, such as a filepath, how do you handle that? I realize globals are generally frowned upon, so what is usually done? Thanks.

Edited by davej
Link to comment
Share on other sites

To answer my own question -- it looks like these can go in the web.xml file. Servlets can retrieve constants defined using the <context-param> tag using the call context.getInitParameter(). I don't know if JSP's can also access these items with a scriptlet. There is also a <init-param> tag.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...