Applet streaming to Servlet
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Carlos_Campos
Posted On:   Friday, November 29, 2002 05:51 PM

Hi Javaneses, I try to send a long String from a Applet (using Internet Explorer 5.5) to a Servlet (using JDK 1.3.0) with ObjectOutputstream.writeObject(), flush(), close() and the ObjectInputstream.readObject(), close() methods. But the String was read incomplete (truncated) in the Servlet. I know that JVM from browsers uses JDK 1.x and have limitations in the String length and others. Question: How can i send large fields from a form in a Applet (MEMO field for example) to my Servlet without truncate the result to be put in the database ??? I appreciate any help. Regards, Carlos Campos Rio de Janeiro Brazil    More>>

Hi Javaneses,

I try to send a long String from a Applet (using Internet Explorer 5.5) to a Servlet (using JDK 1.3.0) with ObjectOutputstream.writeObject(), flush(), close() and the ObjectInputstream.readObject(), close() methods. But the String was read incomplete (truncated) in the Servlet.

I know that JVM from browsers uses JDK 1.x and have limitations in the String length and others.

Question: How can i send large fields from a form in a Applet (MEMO field for example) to my Servlet without truncate the result to be put in the database ???

I appreciate any help.

Regards,

Carlos Campos
Rio de Janeiro
Brazil

   <<Less

Re: Applet streaming to Servlet

Posted By:   Gautam_Marwaha  
Posted On:   Sunday, December 1, 2002 10:45 PM

You could send reasonably big data from an applet to a servlet (will get handled in doPost() method as follows (for reference only - incomplete):

//put data in bytestream
byteStream = new ByteArrayOutputStream();
out = new PrintWriter(byteStream, true);
out.print(....);
out.flush();

//Set up connection and write out the bytestream
dataURL = new URL(servletURI);
connection = dataURL.openConnection();
connection.setUseCaches(false);
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestProperty("Content-Length", String.valueOf(byteStream.size()));
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
byteStream.writeTo(connection.getOutputStream());
byteStream.flush();
About | Sitemap | Contact