• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

writing file on server side through applet

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am developing an application whichi will run on client-server basis.as the clients run the application which is an applet,on the server side i want to keep a log of all transactions.
so through applet how to create a file on server side.
i am using ibm logging toolkit for logging facility
thanks in advance
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Applets are just program code that run on the client. You can of course instruct the applet to retrieve other objects from the same server (data files or images, for example), but there's no stateful "applet connection" between client and server, and no file upload capability.
To do what you want, you need ftp, or a servlet that handles uploads, or some supplemental technique. You can of course integrate this into your applet, but the applet class itself does not directly support what you want to do.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can make an applet write a file to a server if the applet opens a URLConnection to a server application (for example, a servlet) and writes the date through the connection. The server application is responsible for storing the data it receives.
However, you were interested in logging, you said. For basic info, this is done automatically into the server's access and/or error logs. If you need to capture more info -- such as data transferred in a POST operation -- you'll need to code that in the server app. None of that requires any client-side action.
Nor should it. Clients can be hacked much easier than servers can, so it's wise to trust them no more than necessary.
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I assume one would use the getOutputStream method of the URLConnection. Does this perform a post?
If so, how do you know what property of the post contains the file data?
If no, what code would you need to write on the servlet side to accept the output stream?
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HttpURLConnection can do a GET or a POST. The returned output stream is the actual data transmitted - that is, if your request resulted in an HTML response, you'd get back exactly the same data as a web browser would. The HttpURLConnection facility also has the ability to retrieve the response's associated headers, cookies, etc.
I don't do this often enough to have the details committed to memory, so I'd have to RTFM to give specifics, but the information's well enough documented.
[ March 21, 2003: Message edited by: Tim Holloway ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic