Hi Gerardo
I couldn't understand what exactly is your problem is.
If ur are not receiving any object in the servlet side then it could be
because of
u not connecting to it.
U have just opened a connection to the servlet.
u haven't actually connected to it by saying
ServletConnection.connect();
Is this ur problem. If so do i make any sense.
Regards
Nikesh.
Gerardo Macari wrote:
> Hi,
>
> I am trying to send a serialised object to a java servlet. I am using JRun 2.3
> on NT 4.0.
> The applet code is:
>
> try
> {
> URL servletURL = new URL("http://s_webdev2/servlet/EmailServlet");
> URLConnection servletConnection = servletURL.openConnection();
> ObjectOutputStream outputToServlet;
>
> /* Inform the connection that we will send output and receive input */
>
> servletConnection.setDoOutput(true);
> servletConnection.setDoInput(true);
>
> /* Don't use a cached version of URL Connection */
>
> servletConnection.setUseCaches(false);
> servletConnection.setDefaultUseCaches(false);
>
> /* Set the content that we will be sending binary data */
>
> servletConnection.setRequestProperty("Content-Type",
> "application/octet-stream");
>
> outputToServlet = new
> ObjectOutputStream(servletConnection.getOutputStream());
>
> /* Serialise the object */
>
> outputToServlet.writeObject(emailSerialisedObject);
>
> /* Actually send the object now */
>
> outputToServlet.flush();
> outputToServlet.close();
> }
> catch(MalformedURLException mfurle)
> {
> System.out.println("Error sending serialised Object was mfurle" +
> mfurle.getMessage());
> }
> catch(IOException ioe)
> {
> System.out.println("Error sending serialised Object was ioe " +
> ioe.toString());
> }
> }
>
> The servlet code is:
>
> public synchronized void doPost(HttpServletRequest req, HttpServletResponse
> res)
> {
> try
> {
> ObjectInputStream inputFromApplet = new
> ObjectInputStream(req.getInputStream());
>
> EmailSerialisedObject emailObject = (EmailSerialisedObject)
> inputFromApplet.readObject();
>
> inputFromApplet.close();
> }
> catch(Exception e)
> {
> log("Error from servlet was " + e.getMessage());
> }
> }
>
> where EmailSerialisedObject is my object which implemented Serializable
> interface.
>
> please help!!
>
> thanks in advance
>
> gerardo
___________________________________________________________________________
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