The PrintStream you are using inserts line feeds and other garbage. Try using
something like ServletOutputStream. The following is from the JavaDoc for
PrintStream:

All characters printed by a PrintStream are converted into bytes using the
platform's default character encoding. The PrintWriter class should be used in
situations that require writing characters rather than bytes.

~David




|--------+----------------------->
|        |                       |
|        |          gounder72@hot|
|        |          mail.com     |
|        |                       |
|        |          05/01/2001   |
|        |          04:30 PM     |
|        |          Please       |
|        |          respond to   |
|        |          SERVLET-INTER|
|        |          EST          |
|        |                       |
|--------+----------------------->
  >----------------------------------------------------------------------------|
  |                                                                            |
  |       To:     [EMAIL PROTECTED]                                |
  |       cc:     (bcc: David B Valentine)                                     |
  |       Subject:     Re: POST from servlet                                   |
  >----------------------------------------------------------------------------|






if i were to read an audio file and do the POST to servlet with name value
pair .. name been the name of the audio file and value been the content of
the audio file, how would i do that? the servlet does a get parameter on the
name and thereby extracts the contents of the audio file as a string object.
the servlet then copies the string into a file to regenerate the audio file
at the server side.

how can i do this? i tried the following code but the file created at the
server was corrupt audio file. i DONT want to use multipart  to do the file
content transfer.

any help will be of immense help.

sathish
*********************************************
import java.net.*;
import java.io.*;
import java.util.*;

public class DoPOST
{
    HttpURLConnection connection = null;
    public DoPOST()
    {
        try
        {
               URL t_url = new
URL("http://192.138.90.31/servlet/DummyRecordServlet";);
               connection = (HttpURLConnection)t_url.openConnection();
               connection.setUseCaches(false);
               connection.setDoOutput(true);
               connection.setDoInput(true);

               PrintStream out = new
PrintStream(connection.getOutputStream());

               out.print("eight.wav=");

               FileInputStream fis = new FileInputStream(new
File("eight.wav"));
                int temp1;
               while((temp1=fis.read())!=-1)
               {
                 out.print(temp1);
               }

               out.close();

               BufferedInputStream bis = new
BufferedInputStream(connection.getInputStream());

               int temp;
               while((temp=bis.read())!=-1)
               {
                   System.out.print((char)temp);
               }
         }
         catch (IOException e)
         {
            System.out.println("IO exception");
         }
         finally
         {
             if (connection != null)
             {
                 connection.disconnect();
             }
         }
    }

    public static void main(String [] args)
    {
     DoPOST dp = new DoPOST();
    }
}

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html




This communication is for informational purposes only.  It is not intended as
an offer or solicitation for the purchase or sale of any financial instrument
or as an official confirmation of any transaction. All market prices, data
and other information are not warranted as to completeness or accuracy and
are subject to change without notice. Any comments or statements made herein
do not necessarily reflect those of J.P. Morgan Chase & Co., its
subsidiaries and affiliates.

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to