• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSPs, Beans, and properties

 
S Bryan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm fairly new to java and especially new to java web application development. I have a question that I thought would be easy to find the answer to on my own, but apparently isn't:

I would like to develop a straightforward web application using JSP, taglibs, and Java Beans and a standard servlet container like Tomcat. I would like to have a single central configuration file for this application that is accessible from both a bean and from any JSP.

Specifically, I'd like to use a standard java properties file and have the properties accessible to both beans and JSPs automatically, without having to explicitly write code to open the properties file. I just want my properties to be available to both beans and JSPs automagically without any excessive contortions to make this happen.

Is this possible? I know of frameworks like Spring and Stripes that simplify a lot of the aspects of Java web application development. Do either of these frameworks support a feature like this?

This seems like something that should work out of the box, but doesn't -- or at least hasn't for me. Any help with this problem would be greatly appreciated.
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi S E. ,
It looks like your display name does not follow the Javaranch Naming policy on screen names. Basically your display name must consist of a first name and a last name and must not be obviously fictitious.
Please change it using the My Profile link above.

Thanks,
Amit.
Javaranch Moderator
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do this by reading the properties file from a context listener and binding the properties object to context scope.

Once this is done, any of my web resources (servlets, jsps, filters, etc) are able to access the properties object by calling context.getAttribute.
If they're going to be needed by any beans or external Java objects, I pass those objects a reference to the properties object.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!