Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Run time JSP mappings to Struts 2.0 Actions

 
Fawad Ali
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
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.
Web Application.
First Event
intro.jsp

Second Event
intro.jsp

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.

I hope I have explained it well.

Thanks in advance.
 
Tom Rispoli
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

Dispatcher.getInstance().getConfigurationManager().getConfiguration().rebuildRuntimeConfiguration();

I've never done this, but if that works better for you, you might want to give it a try.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic