"Dola Woolfe" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > > --- Bill Barker <[EMAIL PROTECTED]> wrote: > >> >> "Dola Woolfe" <[EMAIL PROTECTED]> wrote in message >> > news:[EMAIL PROTECTED] >> > Hi, >> > >> > This question will reveal how little I know about >> > networking or http or something else. >> > >> > Basically I wrote an applet that sends data to a >> > servlet. I do it by forming a url with a query >> string >> > (GET). But this doesn't work when there's too much >> > data. >> > >> > What are my options? >> > Is it possible to use POST? >> > Or, better yet, is it possible to send a java >> object >> > by creating a socket connection with the servlet? >> > >> >> Actually, combining these two is often easiest (of >> course, your java Object >> must implement Serializable for this to work). >> Something like (Applet >> code): >> >> URL servlet = new URL(getDocumentBase(), >> "/path/to/my/servlet"); >> HttpURLConnection conn = >> (HttpURLConnection)servlet.openConnection(); >> conn.setDoInput(true); >> conn.setDoOutput(true); >> conn.setRequestMethod("POST"); >> conn.setHeaderField("Content-Type", >> "application/x-java"); >> ObjectOutputStream out = new >> ObjectOutputStream(conn.getOutputStream()); >> out.writeObject(myObject); >> int status = conn.getResponseCode(); >> if(isOK(status)) { >> InputStream in = conn.getInputStream(); >> // Handle response here. >> } >> > That's fantastic! And what does the jsp side look > like? I only know how to get data through > getParameter... >
Would use a Filter or Controller-Servlet to do this instead of a jsp myself, but that's mostly a style issue. In any case, the code is the same wherever it lives: <% ObjectInputStream ins = new ObjectInputStream(request.getInputStream()); MyClass myObject = (MyClass)ins.readObject(); %> Of course, the definition of MyClass visible to the webapp has to be the same as it is to the Applet for this to work. Assuming that the definition of MyClass is in the same jar as the Applet (say, applet.jar), then having an identical copy of applet.jar in WEB-INF/lib should work. > > Thanks! >> >> > Very many thanks in advance! >> > >> > Dola >> > >> > __________________________________________________ >> > Do You Yahoo!? >> > Tired of spam? Yahoo! Mail has the best spam >> protection around >> > http://mail.yahoo.com >> >> >> >> >> > --------------------------------------------------------------------- >> To unsubscribe, e-mail: >> [EMAIL PROTECTED] >> For additional commands, e-mail: >> [EMAIL PROTECTED] >> >> > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]