Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-21-2009, 04:24 PM
Member
 
Join Date: Aug 2008
Posts: 14
Rep Power: 0
khdani is on a distinguished road
Default load xml file in servlet help please
Hello,
i use myEclipse for creating a servlet.
i'm trying to load xml file in servlet..but i don't understand where
i should put the file in real path and/or how to load the file.
thank you
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 10-05-2009, 11:06 PM
travishein's Avatar
Senior Member
 
Join Date: Sep 2009
Location: Canada
Posts: 355
Rep Power: 1
travishein is on a distinguished road
Default
the best place to put things like data (xml files) is inside the WEB-INF folder, if it is desireable to have the XML file live within the web application. and then the method ServletContext#getResourceAsStream() is useful for figuring out the deployment-dependent path relative to the webapplication, and fetching you an open InputStream, which can then be used with the XML parsers.

If the XML file must exist externally to the web application, a good idea is to define an context parameter in the web.xml, or maybe use a JNDI environmnt variable name, which can be overridden with the container-specific deployment descriptor. for example, tomcat's context.xml could provider the resource binding for the physical external to the web application path, and the code inside your webapp would fetch a handle to the jndi variable name in a deployment-independent manner.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 10-05-2009, 11:28 PM
Member
 
Join Date: Aug 2008
Posts: 14
Rep Power: 0
khdani is on a distinguished road
Default
Thank You for your reply,
I've already finished developing this servlet,
if I remember correctly, the way you described, that's the way I used to load the xml file, which was part of the web application.

Thank You
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Load file to data structure TinoJF New To Java 4 03-31-2009 04:16 PM
Is there any way to transfer the file Streams from one servlet to another servlet . HenaPriyadarsini Java Servlet 0 08-30-2008 12:52 PM
Not able to load a properties file Happy9959 New To Java 12 07-29-2008 08:15 AM
how to load a servlet on index.jsp page... sujithc34 Java Servlet 1 01-19-2008 01:28 AM
how to load a file in remote machine christina New To Java 1 08-06-2007 10:33 PM


All times are GMT +2. The time now is 05:14 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org