attachments to web server's virtual directory

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jiten Rao (anonymous_at_discussions.microsoft.com)
Date: 08/24/04


Date: Tue, 24 Aug 2004 08:36:24 -0700

Hello,
           I have created a virtual directory on IIS 5.0's
defaul web server. I am trying to put attachments through
the following Java code. <conn.setRequestMethod("PUT");>
But I get an exception on the virtual directory. Could
any one of you advise if there is a problem with IIS 5.0
accepting attachments and calls such as :
 <conn.setRequestMethod("PUT");>

Full details of the code below
/**

    * PUTs the Attachment file to the Virtual Directory
specified

    * in ECO_PARAMS

    */

     public static boolean putFile (String reqURL,
FileInputStream fin) throws Exception {

 

        HttpURLConnection conn = null;

        URL url= null;

        String line = new String();

        StringBuffer buf = new StringBuffer();

        String retval = new String("Not Defined");

        BufferedOutputStream bo = null;

        boolean success = false;

                        String err_message = "This is For
testing";

        try {

            url= new URL (reqURL);

            conn = (HttpURLConnection)url.openConnection();

            conn.setDoOutput(true);

            conn.setRequestMethod("PUT");

 

            byte[] block = new byte[1];

            int readval =0;

            bo = new BufferedOutputStream
(conn.getOutputStream());

 

            while (readval > -1) {

 

              readval = fin.read(block,0,1);

              bo.write(block,0,1);

 

            }

            fin.close();

             eCO_API_Servlet_Utils.write_trans_log_servlet
( local_program_details, err_message );

            bo.close();

             eCO_API_Servlet_Utils.write_trans_log_servlet
( local_program_details, err_message );

 

 

           InputStreamReader in = new InputStreamReader
(conn.getInputStream());

           BufferedReader data = new BufferedReader(in);

 

            while ((line = data.readLine()) != null) {

                buf.append(line + "\n");

            }

            retval = buf.toString();

            in.close();

             eCO_API_Servlet_Utils.write_trans_log_servlet
( local_program_details, err_message );

            return true;

 

        } catch (Exception e) {

 

           Exception ex = new IOException (e.getMessage());

           throw ex;

        }

     }

    /** End of PUT */

}

 



Relevant Pages