thanks Maxim,
But still it doesnt working. I am using Java Plugin on the Client side. Do
you think that it might be the reason of all this mess?
Whenever I try to open the ObjectOutputStream on the applet side, it'll give
me a FileNotFoundException "127.0.0.1/FileReadServlet" ( in the console of
Java Plugin).
So, any idea about that?
Thanks and Best Regards,
Rashid.
----- Original Message -----
From: Maxim Nikitin <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 22, 1999 4:48 PM
Subject: Re: Help!!! Applet-Servlet
> >
> > Hi.
> > > Hi,
> > > I am trying to transfer data from client machine to server using
> > > applet-servlet communication. But it seems that my applet cannot
> > > open an Output stream with the servlet. However, I can send data
> > > from servlet to applet. Here is the concerned part of code....
> > >
> > > MyApplet.java
> > > >>URL codebase = this.getCodeBase();
> > > >>String host = codebase.getHost();
> > > >>String protocol = codebase.getProtocol();
> > > >>int port = codebase.getPort();
> > > >>// Build the URL for the servlet web server
> > > >>URL webBase = new URL(protocol + "://" + host + ":" + port);
> > > >>servlet = new URL(webBase, "/FileReadServlet");
> >
> > 1)You can to do overwise :))
> > servlet = new URL(codeBase, "/FileReadServlet");
> > But it is not decision you problem :)))
> >
> > > >>label.setText(protocol + "://" + host + ":" +
> > > port+"/MyServlet"); // no need to put in servlets directory
>
> I'am sorry I forget
> HttpURLConnection con = servlet.openConnection();
>
> > > >>con.setDoOutput(true);
> > > >>con.setDoInput(true);
> > > >>con.setUseCaches(false);
>
> con.setRequestMethod("POST");
>
> > > >>con.setRequestProperty("Content-Type",
> > > "application/x-www-form-urlencoded");
> 2)Try to do it
>
> con.setRequestProperty("Content-Type",
> "application/x-www-form-urlencoded, boundary=<separator>");
>
> <separator> - Look http://andrew2.andrew.cmu.edu/rfc/rfc1867.html
>
> > > >> file://con.connect();
> > > >>OutputStream out = con.getOutputStream();
> > > >>//
> > > >>ObjectOutputStream os = new ObjectOutputStream(out);
> > > >>os.writeObject(new String("Hello"));
> > > MyServlet.java
> > > >>ObjectInputStream ds = new ObjectInputStream( req.getInputStream());
> > > >>System.out.println("Openend stream with the client"+
> > > req.getRemoteHost());
> > > >> try{
> > > >> String st = (String)ds.readObject();
> > > >> System.out.println(st);
> > > >> }
> > > >> catch( Exception e) {System.out.println("Exception in
> > > conversion");}
> > > Well, the whole system seems to be doing nothing whenever I try
> > > to open the outputstream from applet to servlet.
> > > I'll highly appreciate if you can suggest some solution,
> > > Thanks in advance,
> > > Rashid.
> >
> > Regards,
> > Mank.
>
>
___________________________________________________________________________
> 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
___________________________________________________________________________
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