|
Am I right in thinking that if I could download a file , then I should be able to get this file from my java program? rgds, Rajesh Anand Email:Rajesh_anand@xxxxxx -----Original Message----- From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Magne Kofoed Sent: 15 December 2004 00:02 To: Java Programming on and around the iSeries / AS400 Subject: Re: Sending XML using HTTp server from as400 Hi, it depends what kind of service you get from the http server/service. Post, get, soap? SSL? If you just want to transfer some data through an URL and get an answer in return: Example: java URLDialog <url> <path> <returnfile> If you run on the iSeries (path=.): java URLDialog http://80.203.193.6/cgidev2p/urldialog.pgm? user=mko . answer.html Example on a local pc: java URLDialog http://80.203.193.6/cgidev2p/urldialog.pgm? user=mko e:\test\sockets answer.html Java code: import java.io.*; import java.net.*; public class URLDialog { public static void main(String[] args) throws Exception { if (args.length != 3) { System.err.println("Usage: java URLDialog " + "[url] [path] [file]"); System.exit(1); } String web = args[0]; String path = args[1]; String filename = args[2]; URL url = new URL(web); URLConnection connection = url.openConnection(); connection.setDoOutput(true); PrintWriter out = new PrintWriter( connection.getOutputStream()); out.close(); BufferedReader in = new BufferedReader( new InputStreamReader( connection.getInputStream ())); String inputLine; File outputFile = new File(path , filename); System.out.println("Destination: " + path); try{ PrintWriter outFileStream = new PrintWriter(new FileOutputStream(outputFile)); while ((inputLine = in.readLine()) != null) outFileStream.println(inputLine); outFileStream.flush(); outFileStream.close(); in.close(); }catch (IOException exc){ System.out.println("Error opening file! Does Directory exist?"); System.exit(1); } } } Rgds, Magne Hi Folks, I've a XML file created on as400. I want to send it to a website directly. Has anyone done this kind of thing before? If you have, then can you provide us with a working example. Many Thanks in advance. Rajesh Anand Email:Rajesh_anand@xxxxxx -- This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/java400-l or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l. -------------------------------------------------------- If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail. http://www.ml.com/email_terms/ --------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.