• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

StrutsConfig.xml dilemma

 
Ranch Hand
Posts: 1283
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been asked several time this question can we create more than one strutsconfig.xml file or can we have more than one action servlet in our struts application... What would be the appropriate answer for this question or what is the intention to ask this question please let me know... thanks

 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Yes, we can have multiple struts-configs in single struts application. we can declare that in web.xml.
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about the ambiguity? and is there any particular reason to ask this question?
 
Ranch Hand
Posts: 448
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kaustubh G Sharma wrote:What about the ambiguity? and is there any particular reason to ask this question?



Hi Kaustubh,

I have also been asked this question 5 out of 20 interviews i have faced.
I have asked this question in 2 of the 5 interviews that I have taken.

Probably as a developer we focus on single files and don't have much knowledge about this aspect and interviews are simply to ask those absurd questions which have very less meaning in terms of actual work....

The answer is yes there can be multiple config files with comma separated to the ActionServlet in web.xml. The advantage is that we can split one big config to multiple smaller manageable configs.

In case of ambiguity the later one will override the earlier mapping. Its like refreshing a value for a key in hashmap.....
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmmm Thanks Sunny
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sunny Bhandari wrote:

Kaustubh G Sharma wrote:What about the ambiguity? and is there any particular reason to ask this question?



In case of ambiguity the later one will override the earlier mapping. Its like refreshing a value for a key in hashmap.....



didn't get this bro
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

which version of struts you are using?
Including struts 1.1 and onwards they are supporting modules in struts application. In Module based application we can have multiple struts-configs for each module. All module & struts-configs need to declare in web.xml
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1.3 it is.. but actually we don't create separate struts config file per module ..
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think this link will help you

http://www.roseindia.net/struts/struts2/struts-xml.shtml

Thanking You
Manish
 
Sunny Bhandari
Ranch Hand
Posts: 448
Eclipse IDE Firefox Browser Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kaustubh,

I meant that in case <param-value> in web.xml is a.xml,b,xml and both a and b xmls have same mapping then the mapping from b.xml will be used because it is loaded after a.xml has loaded and will override any conflicting mappings.
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Manish

As Kaustubh is using struts 1.3, He requires help on that as I see link you given it explores struts 2.0

@Kaustubh

refer below link,

configuration

look in to section "5.3.1 Module Configuration Files"

HTH

Thanks,
Shailesh
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Shailesh you info really help me out... But as that article says we can separates multiple strutsconfig file with ',' ... Then Every time when request come to web.xml file then how it figure out which struts config is going to call??
 
Sunny Bhandari
Ranch Hand
Posts: 448
Eclipse IDE Firefox Browser Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kaustubh G Sharma wrote:Thanks Shailesh you info really help me out... But as that article says we can separates multiple strutsconfig file with ',' ... Then Every time when request come to web.xml file then how it figure out which struts config is going to call??



You forgot to read my reply on that?

I meant that in case <param-value> in web.xml is a.xml,b,xml and both a and b xmls have same mapping then the mapping from b.xml will be used because it is loaded after a.xml has loaded and will override any conflicting mappings.
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While parsing all struts config files on start up, struts framework will parse all contains in single configuration object, if two struts config will have same action mapping name then that will be overridden. same thing is Sunny is trying to tell.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A Web.xml can have one or more Struts-Config.xml associated with it
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Shailesh Narkhede wrote:While parsing all struts config files on start up, struts framework will parse all contains in single configuration object, if two struts config will have same action mapping name then that will be overridden. same thing is Sunny is trying to tell.



you want to say if more than one strutsconfig when associated with same mapping then the last strutsconfig will run.. And what about this ActionServlet can we have more than one ActionServlet?
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Never
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Shailesh Narkhede wrote:Never


what is the reason?
 
Sunny Bhandari
Ranch Hand
Posts: 448
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read Front Controller design pattern
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sunny Bhandari wrote:Read Front Controller design pattern



What is this?
 
Ranch Hand
Posts: 433
Netbeans IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://lmgtfy.com/?q=Front%20Controller%20design%20pattern
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joachim Rohde wrote:http://lmgtfy.com/?q=Front%20Controller%20design%20pattern




hahaha thanks I got the solution for my stupid question .. Good one jack
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got this in one post...


ActionServlet is like BackBone of our application, we have done all actions(request & response) by using only one instance, that is ActionServlet's Instance, that is the main reason to go for MVC architecture, no need to create more than one instance, thats why we use only one ActionServlet for whole project.

In Previous Structure, we should create new instance for each and every request, in MVC no need.

Note of it "we have only one Backbone in our BODY"
 
reply
    Bookmark Topic Watch Topic
  • New Topic