An application I'm working on uses the displaytag library and I'd like to set an application wide variable for the pagesize attribute:
I'd like to replace the hard coded page size with something I can set once and read from all the pages. I was thinking as a key in my struts applicationresources.properties file but I don't know how to access that value outsize of the <bean:message> tag.
Most of my background is from ColdFusion where I have an onApplicationStart method where I can store application level properties when my application is started. I can access these properties in my dynamic pages by prepending the variable name with application. . For instance in my onApplicationStart method I'd set:
application.pagesize = 50;
Then in my .cfm pages (similar to my .jsp's) I could use it like:
I'd like to do something similar in my jsp's but I'm not sure how to do it. Anybody have any suggestions?
Thanks for the response, I appreciate it. I tried searching around for what I'm looking for but I don't think I was using the right search terms to find what I was looking for.
I'm pretty green in the Java world, migrating from mostly PHP and ColdFusion. Would you be able to explain a little more about adding a context listener? Is there a method that gets invoked when the application is started that I could use?
Once you've looked this up (use the javadoc and the Servlet spec) post back with any problems you have. This is an important skill to have under your belt if you will be working in web apps.
Joined: Apr 12, 2011
I've got the context listener working, but I ran into what is most likely a simple problem. Here is my context listener code:
The problem that I'm having is that its not loading my xml configuration file. It looks like its looking for the config file (see line 19) right in my tomcat's bin directory. How can I get it to point to my webroot directory?