• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Dynamically Load Struts Config Based On URL

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know this is a rather strange request, so please bare with me.

I'm looking to dynamically load different struts configuration files based on what URL is requested on Action Servlet start up. In other words for www.site1.com I would want to load /WEB-INF/site1-struts-config.xml, and for www.site2.com I would want to load /WEB-INF/site2-struts-config.xml.

Is this possible, and if so how would I go about doing this?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Brian M Smith wrote:please bare with me.


I don't really think of you in that way.

I'm looking to dynamically load different struts configuration files based on what URL is requested on Action Servlet start up. In other words for www.site1.com I would want to load /WEB-INF/site1-struts-config.xml, and for www.site2.com I would want to load /WEB-INF/site2-struts-config.xml.

Is this possible, and if so how would I go about doing this?


The configs are loaded on server startup, not after receiving a request. You'd have to come up with a different way to identify which config you want to load.
 
Brian M Smith
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David,

Thank you for the response. What you are saying makes sense. I was thinking that there might be some functionality within struts to dynamically load configuration files, but I guess there isn't. I'll have to rethink my solution.
 
Brian M Smith
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wanted to bring up another idea that is slightly different.

Would it be possible to load one struts-config.xml file that is blank or has some common actions in it, and then load additional struts configuration files from that watered down struts-config file?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure; you can use multiple configuration files. You'd still have to decide which ones to use if you're bundling them all in each app, though.
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Multiple struts config files get loaded when web app gets deployed.
Have look at the 5.3 Configuring Your Application for Modules from Struts 1 site, it describe the basic setup, the configuration and how to switch between module.

Bytheway, why do you want to site1.com and site2. com has same IP address and accessing the same web app, I don't think this is true in real world .
 
Brian M Smith
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sagar,

Thanks for the reply. I know that I can load multiple struts-config files via comma delimited string. What I'm talking about doing is dynamically appending an additional configuration file into that comma delimited string based on incoming URL. I know this is a rather strange request, but I'm using SAP's web container to run various sites. The idea is that we are trying to consolidate our code base for maintenance purposes., including struts configuration files and JSP.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then each web app should have its own set of config files (with possibly some being the same between sites). I'm not sure if S1 allows config files on the classpath (haven't used S1 in a half-decade now), which would make things easier.
 
Brian M Smith
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:. . .(haven't used S1 in a half-decade now). . .


Yeah that's the problem with all the web applications my company is considering. All of them are monolithic apps, SAP ISA/WebSphere Commerce. All of these applications use very old versions of struts 1 and very old EJB specs. Upgrading to Struts 2 is simply not an option from a cost perspective.

Oh well, I guess we'll just have to accept the fact that we will have to maintain multiple code bases. I appreciate the replies gentlemen!
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's no reason common functionality can't be put into jars, and quite a bit can be done to split things up/pull things together during the build process.
 
Brian M Smith
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:There's no reason common functionality can't be put into jars, and quite a bit can be done to split things up/pull things together during the build process.



We have already done that. All of our backend code, and even our actions will be pulled from one code base. We are trying to figure out where we should make the split from a global code base to multiple code bases. Clearly the JSP's will need to be multiple code bases, but we where hoping that we could move the controller layer into a global code base since all of our actions will be in that global code base.
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Frankly speaking, I haven't understood what you guys talking about. The SAP and multiple code base is never-heard thing to me. I'm simple developer with maintaing a single simple site

I gotta leran the web application complexity.
 
Brian M Smith
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:Frankly speaking, I haven't understood what you guys talking about. The SAP and multiple code base is never-heard thing to me. I'm simple developer with maintaing a single simple site

I gotta leran the web application complexity.



SAP is a giant application that does a lot of different things (http://www.sap.com/usa/index.epx). I'm working with the e-commerce portion of the application, which is called ISA.

The multiple code base issue is about making code easy to maintain across many different sites. For instance, let's say you have a common piece of functionality that is used on 7 sites that you want to change. You want to set up your development environment so that you only have to change it in one place instead of 7 different places. What I'm trying to do is set up a development environment where I can try to share struts configuration files between multiple applications without having to create separate configuration files for every site.
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Brian M Smith wrote:What I'm trying to do is set up a development environment where I can try to share struts configuration files between multiple applications without having to create separate configuration files for every site.


Then you have to change the underlying server code which loads the struts-config.xml into the memory every time the web app redeployed, want more easy approach, try considering copy paste option..
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Copy-paste == bad.

I threaten to remove the ctrl-V keys, menu options, etc. on all my developers.
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:Copy-paste == bad.
I threaten to remove the ctrl-V keys, menu options, etc. on all my developers.



Thanks God, I' don't work under you (Actually, I like to, but No, I love this copy-paste thing man, that's the best invention about Computer usage)
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I feel precisely the opposite: pasting makes it too easy to not do things the right way: refactoring, restructuring, cleaning.
 
I'm not dead! I feel happy! I'd like to go for a walk! I'll even read a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic