Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-05-2008, 05:17 PM
Member
 
Join Date: Jul 2008
Posts: 7
Rep Power: 0
keioGirl is on a distinguished road
Default Retrieving xml file from Web Server
If I put my xml files in Apache HttpWebServer, how can I retrive those files in java. I think File API - new File(directoryPath).listFiles() cannot be used for web applications.
And in DOM and xpath, I cannot retrive files which exists in other folders outside the Project folder. DOM cannot find it. Is there any way I can retrieve which exists in Appache HttpWebServer?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 12-06-2008, 09:40 AM
Member
 
Join Date: Dec 2008
Posts: 6
Rep Power: 0
w3user is on a distinguished road
Default
Each of your xml file can be identified by its url.
Use apache httpclient APIs to read the content of url.
here's the tutorial link:
hc.apache.org/httpclient-3.x/tutorial.html

sample code:
String url="your xml file url";
GetMethod method = new GetMethod(url);
int statusCode = client.executeMethod(method);
byte[] responseBody = method.getResponseBody();
String fileContent=new String(responseBody);
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-01-2009, 09:19 PM
Member
 
Join Date: Jul 2008
Posts: 7
Rep Power: 0
keioGirl is on a distinguished road
Default
Thanks.
But the problem is I would like to get like 30 xml files simultaneously (example: by using some looping or like "..//localhost/8080/*.xml" though I know that *.xml doesn't work) without defining each specific url. How should I do that?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-14-2009, 09:44 PM
Member
 
Join Date: Sep 2008
Posts: 43
Rep Power: 0
2potatocakes is on a distinguished road
Default
mmmm.. I'm also really curious as to how to do this. Does anyone know?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 01-15-2009, 11:28 AM
Member
 
Join Date: Jan 2009
Posts: 4
Rep Power: 0
mox8iro is on a distinguished road
Default
hi,
is there any naming convention of the xml files? do you know the number of files you want to get?
if there is a specific pattern of naming the xml files maybe you will be able to retrieve them..
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 01-16-2009, 05:36 PM
Steve11235's Avatar
Senior Member
 
Join Date: Dec 2008
Posts: 798
Rep Power: 1
Steve11235 is on a distinguished road
Default
Without providing any specifics on how to do this, I can tell you that a Web server will provide a directory listing *if* directory listing is authorized. So, the Web server has to be configured to allow listing. It will typically provide the list as an HTML page. You can test this from a browser by //http:url/ (no page specified). I would start by getting the Web server to provide a listing and then testing with a browser, to see what the output looks like.

Web servers generally *do not* allow listing, to prevent people from seeing everything on the server, so if you don't control the server, you may not be able to get a listing.

The other option is to have whoever is posting the files either use standard names, such as name-2009-01-16-x.xml, where the x is a sequence number 1,2,3,.., or have them place a list of names in an xml file on the server and update the file contents every time they post new files.
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
How to create file on server? thevoice New To Java 8 01-15-2009 09:34 AM
Does any file in an FTP server ends up in an HTTP server? islamfunny CLDC and MIDP 4 08-15-2008 04:30 PM
storing and retrieving a file as such anil_manu Advanced Java 0 03-11-2008 01:27 PM
Checking of file was modified on the server Java Tip Java Tips 0 03-02-2008 07:18 PM
Retrieving serialized objects from file JavaForums Java Blogs 0 11-07-2007 09:03 PM


All times are GMT +2. The time now is 08:18 AM.



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