File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Run time JSP mappings to Struts 2.0 Actions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Run time JSP mappings to Struts 2.0 Actions" Watch "Run time JSP mappings to Struts 2.0 Actions" New topic

Run time JSP mappings to Struts 2.0 Actions

Fawad Ali
Ranch Hand

Joined: Dec 28, 2009
Posts: 115
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

Second Event

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.

Regards, Fawad Ali.
Software Engineer, Stafona Inc. - My Blog
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
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:


I've never done this, but if that works better for you, you might want to give it a try.
I agree. Here's the link:
subject: Run time JSP mappings to Struts 2.0 Actions
It's not a secret anymore!