Hi Drew,
I did something that looks quite like what you want to do,
I have a servlet that send a reques to a search engine that in turns
return an xml document.

For my project I write the result to a file, but its the same
to write it to the outstream...
Basicalyy I do as follows:

.............................
         URL u = new  URL(xmlQueryUrl); // xmlQueryUrl: the url of my search
engine

         // Open the connection and prepare to POST
         URLConnection uc = u.openConnection();

         String User = this.docServerUser+":"+this.docServerPwd ; //it's pwd
protected toI prepare my login

         String encoding = new
sun.misc.BASE64Encoder().encode(User.getBytes());

         uc.setRequestProperty("Authorization", "Basic " + encoding);

         uc.setRequestProperty("User-Agent","wcoomd-hs-app-UA");

         uc.setDoOutput(true);

         uc.setDoInput(true);

         uc.setAllowUserInteraction(false);

         DataOutputStream dstream = new
DataOutputStream(uc.getOutputStream());

         dstream.writeBytes
 "pattern="+java.net.URLEncoder.encode(pattern)); //my search parameters...

         dstream.writeBytes
 "&hsversion="+java.net.URLEncoder.encode(hsversion));

         dstream.close();

        // Read Response
        DataInputStream dis = new DataInputStream(uc.getInputStream());

        StringBuffer result= new StringBuffer();

/*allows to check that the return is ok*/
boolean eof=false;

String xmlfilename= tempFolder+(new
java.util.Date()).getTime()+session.getAttribute("userId")+".xml";

.............................
    java.io.FileOutputStream tempFile = new java.io.FileOutputStream
(xmlfilename);

    while (!eof) {
      String ress=dis.readLine();
      if (ress==null)
        eof=true;
      else
        tempFile.write (ress.getBytes());
    }

    tempFile.close() ;
.............................


-----Original Message-----
From: Drew Falkman [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 20, 2002 5:22 PM
To: JRun-Talk
Subject: Web Page as a stream


Hey all-

Does anyone know of a good way to open another Web page and process it as a
stream using Java - similar to what CFHTTP does in ColdFusion?

I want to read a dynamic, XML-compliant Web page from another site and
perform an XSLT transformation on it and am looking for the best way to do
it.  Additionally, I could parse a WHOIS result, or use it in other ways.

Thanks,

Drew Falkman
Author, JRun Web Application Construction Kit
http://www.drewfalkman.com

______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to