This guy is so lazy!!!<br />There is nothing left!
Nick Potter
Ranch Hand
Joined: May 07, 2008
Posts: 125
posted
0
Yes, using context-param
Ramkumar Subburaj
Ranch Hand
Joined: Sep 07, 2007
Posts: 83
posted
0
hi thanks for the reply.
what does this exactly mean
stef li
Greenhorn
Joined: Jan 16, 2006
Posts: 27
posted
0
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
Joined: May 07, 2008
Posts: 125
posted
0
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
Joined: Sep 07, 2007
Posts: 83
posted
0
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.
Ashwin Pai
Ranch Hand
Joined: May 20, 2008
Posts: 90
posted
0
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
The only way to make your dream come true is to wake up.
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.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35223
7
posted
0
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)?
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
Joined: Sep 07, 2007
Posts: 83
posted
0
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
Joined: May 07, 2008
Posts: 125
posted
0
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.
Bauke Scholtz
Ranch Hand
Joined: Oct 08, 2006
Posts: 2458
posted
0
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.
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
Marshal
Joined: Mar 22, 2005
Posts: 35223
7
posted
0
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.
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.
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.