-2

How can i save a file on gwt-server site in a gwt RemoteServiceServlet? The location should be folder under the war directory in tomcat. Is it in a RemoteServiceServlet possible without use FileUpload on client site?

ChHaupt
  • 363
  • 3
  • 6
  • 17

2 Answers2

2

You can write files at serverside.

File f = new File("/my/path/file.txt");
FileOutputStream fos = new FileOutputStream(f);
fos.write("text".getBytes("UTF-8"));
fols.close();

If that file should be uploaded you have to make a Upload first: http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/user/client/ui/FileUpload.html

Maybe, this project helps: http://code.google.com/p/lib-gwt-file/

GWT: Google Web Toolkit

A framework to create JavaScript which is running in a browser at clientside

GAE: Google App Engine

A Server infratructure, which allows to create applications, which are running at google server farm. Files are available via Blobstore API

Christian Kuetbach
  • 15,850
  • 5
  • 43
  • 79
  • I dont want to upload the File and the FileOutputStream is not supported by GAE. – ChHaupt Jan 25 '13 at 16:06
  • FWIW, my prev comment is @ChHaupt, not Christian. – Taylor Jan 25 '13 at 23:35
  • I think a GWT applications always runs in the GAE and not in the JAVA VM. – ChHaupt Jan 27 '13 at 10:53
  • No. GWT applications run in the JavaSCript VM of the browser. In fact it will work if loaded from the filesystem. GWT has NO dependency to GAE. – Christian Kuetbach Jan 27 '13 at 11:15
  • The client site. But the server site? – ChHaupt Jan 27 '13 at 11:17
  • GWT runns inside a web-application container. Within a ormal container, you can use 'FileOutputStream'. If you run inside the GAE-container, you need to use the BlobStore: https://developers.google.com/appengine/docs/java/blobstore/overview – Christian Kuetbach Jan 27 '13 at 11:21
  • You know that a blobstore was realised with a client request on the server and i dont wont to do a client request? – ChHaupt Jan 27 '13 at 11:22
  • ChHaupt, GWT is a client side framework that can be used on top of ANY server side (you can make it work with PHP or ASP.net if you want). Stop being so combative, try explaining your problem more clearly. – Taylor Jan 28 '13 at 15:09
0

FileUpload is only used for generating the correct typed HTML input tag (if you are planning to send your data not via a form).

Jens Peters
  • 2,075
  • 1
  • 22
  • 30