Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing to web space from Java applet.

 
Jesse Miller
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a little unsure of how to approach this so I am open for suggestions. I have an Applet that pulls data from a web server. The user can change the data but when they press a SAVE button I need to write some data in the form of a XML file back to a folder on the server. Right now I have nothing but server space that houses my Applet. What is the best way to go about this? Thanks
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kind of access does the applet have to the server - FTP? WebDAV? Shared directory? If it's just HTTP, then the Java solution would involve servlets (and thus require a servlet container).
 
Jesse Miller
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to do this upload anonymously so doing it by FTP would probably not work. On researching some more it seems that servlets might be what im looking for. But I am still a little unsure of what is required to implement a servlet. What is required server-side to place the uploaded file in a directory and what is required client side to initiate the upload from the local computer? Thanks
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it an actual file you want to upload? It sounds as if it may just be some XML data. If so, then no more than an HTTP POST is required (which the java.net.HttpURLConnection class can handle). On the server side you'd need a servlet container such as Tomcat (or Jetty, Resin, GlassFish, JBoss, WebLogic, WebSphere etc.).
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lester Burnham wrote:On the server side you'd need a servlet container such as Tomcat (or Jetty, Resin, GlassFish, JBoss, WebLogic, WebSphere etc.).


But it sounds like Jesse won't be able to install anything like that in his "nothing but server space". What he can do in that space is an open question.
 
Jesse Miller
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, Iv researched a little bit and have been able to set up a HTML form to submit a HTTP POST request and then a PHP script on the back end to accept it and place the file in an upload directory on my server. This works 100%. But now I need to get this functionality in my Java code. The applet I wrote will create a temporary XML file on the users computer but when the user chooses to save all changes it will upload the entire file to the server. I basically need the functionality of the HTML form that I attached in Java code. I imagine I can just use the same PHP script that I have attached as well. Could anyone start me off with some code or specific examples? Thanks

HTML Form


PHP Script

 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesse Miller wrote:Ok, Iv researched a little bit and have been able to set up a HTML form to submit a HTTP POST request and then a PHP script on the back end to accept it and place the file in an upload directory on my server. This works 100%. But now I need to get this functionality in my Java code.


In other words, you need your applet to issue a POST request with the file attached. Start by reading this tutorial; notice that the parts which cover your requirement are near the bottom of that page.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic