To turn on the option to show the java console of the browser and hence see
all messages (System.out.println) your applet prints, you should:
1 - Go to Control Panel;
2 - Double click on Java Plug-in icon;
3 - Select Show Java console
4 - Click Ok.

Hope this helps,
-Leo


> -----Original Message-----
> From: Johnson Winfrey [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, September 26, 2001 4:25 PM
> To:   [EMAIL PROTECTED]
> Subject:      Re: More on downloading a file
>
> System.out.println DOES show up in the Java Console of the browser showing
> the
> Applet....  which should be fine for debugging/testing purposes but not
> for a
> production environment...
>
> good luck,
>    -john
>
>
>
>
>
>
> Richard Yee <[EMAIL PROTECTED]> on 09/26/2001 04:03:23 PM
>
> Please respond to "A mailing list for discussion about Sun Microsystem's
> Java
>       Servlet API Technology." <[EMAIL PROTECTED]>
>
>
> To:   [EMAIL PROTECTED]
> cc:    (bcc: Winfrey Y Johnson/IT/VANCPOWER)
>
>
> Subject:  Re: More on downloading a file
>
>
>
> Sohalia,
> Note that the System.out.println in your applet code is not going to show
> up anywhere because the there is no console for the Applet to display.
>
> I'd suggest that you have your applet just post to one of the tomcat
> example servlets that will print out the request.  Note that there is not
> much use in having the applet read the response from the servlet because
> it
> won't be able to write the file to the local disk.
>
> You need to use getAppletContext().showDocument(dataURL);  to have the
> servlet response handled by the browser.
>
> This code is working fine in my applet although I am using a GET instead
> of
> a POST.
>
>    public void actionPerformed(ActionEvent event) {
>        try {
>           System.out.println("actionPerformed");
>           //String query= URLEncoder.encode(inputField.getText());
>           String query= inputField.getText();
>           URL currentPage = getCodeBase();
>           String protocol = currentPage.getProtocol();
>           String host = currentPage.getHost();
>           int port = currentPage.getPort();
>           String urlSuffix = "/myapp/servlet/requestInfo?" + query;
>           URL dataURL = new URL(protocol, host, port, urlSuffix);
>           getAppletContext().showDocument(dataURL);
>        }
>        catch (MalformedURLException mue) {
>        }
>     }
>
>
> Regards,
>
> Richard
>
> -Richard
>
>
> At 03:07 PM 9/26/01 -02-30, you wrote:
> >Hi, ok i don't get an error anymore (thank you to those who helped me
> with
> >that). I removed the ObjectOutputStream from my code, but now my servlet
> >doesnt seems to not be run even tho a connection to is is established.
> >(The servletrunner thing where it says the servletname: init thing doesnt
> >happen, which is why i assume its not run)
> >
> >in my applet i call a function
> >
> >downloadFile(data)
> >
> >which contains the following code
> >
> >public void downloadFile(UserData data) throws Exception
> >{
> >         servlet = new URL(webBase, "servlet/FileDownloadServlet");
> >         Serializable objs[] = { data };
> >         URLConnection con = servlet.openConnection();
> >         System.out.println("con open");
> >         con.setDoInput(true);
> >         con.setDoOutput(true);
> >         con.setUseCaches(false);
> >
> >
> >con.setRequestProperty("Content-Type","application/x-www-form-urlencoded"
> );
> >         ObjectOutputStream out = new
> > ObjectOutputStream(con.getOutputStream());
> >         int numObjects = objs.length;
> >         String output = "";
> >         for(int i = 0; i< numObjects; i++)
> >         {
> >             out.writeObject(objs[i]);
> >             output = "done!";
> >         }
> >         out.flush();
> >         out.close();
> >}
> >
> >
> >then the servlet is (no database stuff this time, just trying to dl a
> file
> >from /tmp )
> >
> >public void doPost(HttpServletRequest req, HttpServletResponse resp)
> >         throws ServletException, IOException
> >{
> >         // Open the I/O streams and connection
> >         ObjectInputStream in = new
> ObjectInputStream(req.getInputStream() );
> >         resp.setContentType("text/html");
> >         PrintWriter out = resp.getWriter();
> >         try {
> >             try {
> >                 //get parameter from applet
> >                 UserData data = (UserData)in.readObject();
> >                 out.println("Content-Disposition: attachment;
> >filename="+data.getFileName());
> >                 out.println("Content-Type: application/octet-stream;
> >name=/tmp/"+data.getFileName());
> >                 out.println("Content-Location:
> /tmp/"+data.getFileName());
> >                 out.println("Content-Base: /tmp/"+data.getFileName());
> >             }
> >             catch (java.lang.Exception ex){
> >                     ex.printStackTrace ();
> >             }
> >         } catch (Exception e) { e.printStackTrace(); }
> >         in.close();
> >}
> >
> >
> >Any suggestions?
> >
> >Thanks
> >sohaila
> >
> >_________________________________________________________________________
> __
> >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
>
> __________________________________________________________________________
> _
> 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

Reply via email to