• 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

can web.xml data include contents from other xml file

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

In a web application, can the web.xml dd load configuration from other xml files speciefied in WEB-INF folder.

 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think that this kind of thing can be done...
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, using context-param
 
Ramkumar Subburaj
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi thanks for the reply.

what does this exactly mean

 
stef li
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it means that there are serial config files under the classpath of the project.
the file name is begin with "applicationContext"

 
Nick Potter
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here's an example:
<param-value>/WEB-INF/theXmlThatContainsSomeConfiguration.xml</param-value>

it's the path to your xml file that you want to load
 
Ramkumar Subburaj
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Please tell whether the following configuration is right?

web.xml File:




applicationContextTest.xml File:




I am getting resource not found error when i access the servlet directly.

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

Ramkumar Subburaj wrote:Hello,

In a web application, can the web.xml dd load configuration from other xml files speciefied in WEB-INF folder.



Why would you want to do this ? I see in a subsequent post that you are trying to use a xml file that has the servlet mapping in web.xml
What is the requirement that drives you to do this ?

Ashwin
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A context param does not cause any files to automatically be "included" in the web.xml.

What are you really trying to accomplish?

 
Ramkumar Subburaj
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
we are 3 in the team and working in one project. We find it difficult to maintain the web.xml when clubbing all our modules. so i was thinkig if there was a way to load external xml file, we could use 3 individual xml files during development and while deploying
we can put everything into web.xml

This might(should) sound silly

is there any other better option.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The web.xml file should't be something that changes very frequently. Are you maybe keeping configuration parameters in it that would better be kept in a configuration file (like a properties file)?
 
Nick Potter
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ramkumar Subburaj wrote:
Please tell whether the following configuration is right?

web.xml File:




applicationContextTest.xml File:




I am getting resource not found error when i access the servlet directly.



Of course, because this is incorrect:
<param-value>classpath*:applicationContext*.xml</param-value>
if you have applicationContextTest in application/config/, for example, you put <param-value>config/applicationContextText.xml<param-value/>
 
Ramkumar Subburaj
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nick,

what does this mean

if you have applicationContextTest in application/config/

i believe application/config/ is a path and what does this point to
 
Nick Potter
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where you put the other xml files that you want web.xml to load. I usually keep them in a config folder in the application along with other xml and properties files, but you can put them in any folder in your application. So the param-value should point to their location.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To clear things out, using context-param doesn't load the specified xml file automagically into the web.xml or so. It only make the name available as ServletContext#getInitParameter() so that one could use this information to load the xml file programmatically or so. I have no idea what Nick is thinking or (mis)understanding, but this is really not what you're looking for.

To solve your problem, just use a good CVS.
 
Nick Potter
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I usually put all my servlets in a servlet.xml instead of web.xml, so when the application is loaded it reads the servlet.xml file. I do this using param-values. I assume he wants to do something similar? If i'm doing something wrong (or misunderstand something), what is that?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bauke Scholtz wrote:using context-param doesn't load the specified xml file automagically into the web.xml


Not in a standard servlet container, but the Spring framework can be configured to work this way. That may be what's being talked about here.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nick,
This is creating a lot of confusion.
Did you write a custom clasloader that reads the external xml files and loads the servlet classes?

If not, what container are you using?
There is nothing in the servlet spec that allows external xml files to be automatically loaded.
If your container is doing this then it is probably non spec feature provided by that container.

To avoid this type of confusion we try to keep the conversation here to features provided by the servlet specification so the answers given will work for people using any spec compliant container. If you want to discuss a container specific feature, please let everyone know what container you're using and that your answer applies only to that container.

Thanks,
-Ben
 
Nick Potter
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using spring, yes, sorry if it led to confusion. I've never done a web application without spring.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for clarifying this, Nick.

I was busy searching the servlet 2.5 spec to make sure I didn't miss something new.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When someone posts here without explicitly mentioning that they are using spring (or struts, or whatever) please do not assume that they are. It just sows confusion.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic