I'm leaving this up in case anyone has any input, but I decided it was silly for me to try to do this this way. I just added an "environment" property to each of the beans, put the build.jsp page into the application proper as a view and set it within showForm() if the querystring contains a "build" parameter, and added the environment property to the model.
I have a Spring 2.5 MVC web application that can be deployed with any of several back-end environments. I have a bean for each environment defined in dispatcher-servlet.xml, and depending on the deployment environment, I edit my controller's bean in dispatcher-servlet.xml to reference the appropriate back-end environment bean.
I also have a JSP page accessible to the end user (not in web-inf, not mapped to a servlet), that gives build information. I would like the JSP page to also display the deployment environment information, since that is something that the user can't otherwise tell (the same front-end URL may use any of several different back-end environments).
Is there a way to include the environment bean name or bean id in the JSP page? That would be the id of the bean referenced by projreqController.dbSubmitter in the snippet below.
If you still want to access the bean name you could implement BeanNameAware . This is considered bad practice for an application to have dependencies or to need to know these types of details. This is also mentioned in the javadoc I linked. If you wanted to go this route anyway, when you implement this interface the framework will call the setter defined so you would have to define a bean name field and a getter for it so you could access it.
Previous to Spring adding support for profiles there were other workarounds people had used. If you google around you may be able to find some of them.
Sorry for the off-topic reply, but what's with the spam link at the bottom of the page disguised as a post? I've seen jprofiler, jrebel, and probably others. The fake post reads, "I agree. Here's the link. <link to some software product or other> - it saves me about five hours per week."
Anyway, thank you for the links, Bill. As mentioned, I decided trying to get at the bean names was not a great idea, and I did find a different way to get the information that I wanted into the jsp page.
It looks like using profiles is a lot more complicated than simply editing two bean references in my XML configuration file, so I'll stick with what I've got there. I've really never understood why one wants to use annotations (except for automated testing) for most of what I configure in the XML file. I like having, and one of the originally touted benefits of Spring's dependency injection was having, the ability to get at some of this stuff (to see it and to modify it) outside of the compiled code.
No problem. Just as a note anything you can do with annotations can be done in XML including Bean profiles. One of the links I provided shows the XML way. Also unless you are not building your Spring configuration files inside your WAR it is unlikely somebody will ever crack open a deployed WAR to make changes to the XML, typically you would just rebuild it anyway. Anyways glad you got it figured out.
We deploy these (internal) applications typically to a server that expands the .war files on deployment, and we actually do tinker with the deployed files from time to time. Which is what led to the question. :-)