This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have some kind of complex situation. I am working on a web site where people arranges events. There are a set of public pages which are specific to a particular event. The owner of that event can ask us to customize the jsp pages for them. So each event has its own set of jsp pages in the eventNamed folder. My application is struts 2.0 based. Normal way of this to achieve would be to add the new folder and jsps to the project and then make appropraite actions and action mappings in struts.xml. That way, its easy. But in that case we will have to restart our web server in order to reflect the new jsps and actions upon a new event creation. We do not want a restart of the server. So is there anyway that action class takes the jsps from appropriate eventNamed folder based on some input.
The web structure is like below.
So if I calculate, that the event id FirstEvent, then the jsps should be from FirstEvent folder and vice versa.
Remember that event creation is not manual but it is automated through the application by copying all the jsps to the new Event named folder.
If I understand your problem correctly, you are using the same action class for all of your events, but you are returning a different result for each event and using the struts.xml file to control which directory's JSP the application uses to display the data. If this is correct, then you maybe be able to solve your problem by having a single result that your action class uses any time it completes successfully. This result will go to a JSP that has a jsp:include tag in it that gives control to the correct JSP. I've never put anything dynamic in the "page" attribute of a jsp:include, so I'm not exaclty sure what your options are. I doubt you can use s:property tag, EL might work, if all that fails, you could write a scriptlet (shame on me for saying that).
Alternatively, I you want to automatically update the struts.xml file, I think you can reload it with: