0

Well I am pretty happy working at home with a local Apache Tomcat and serving the static files with help of FileServlet, also I am following a instruction as said in this answer that:

You should not store the files in the webcontent. This will fail when the WAR is not expanded and even when it is, all files will get lost whenever you redeploy the WAR.

But now I am using Google App Engine for my application, where I cannot configure the server, also it usesjetty which is new for me. All the things in my web application gets uploaded to server through eclipse but I cannot upload a folder outside to WAR. Now how can I apply such static file serving here using a Servlet, should I use Google Blobstore? , or just simply a database that can be Google Cloud SQL or there is any other way out?

Thanks,
Asif

Community
  • 1
  • 1
Asif
  • 4,980
  • 8
  • 38
  • 53

2 Answers2

1

The answer in the link does not apply to you: it is saying that one should not upload (i.e. programmatically create) files to webcontent folder.

Just put static files that you want to be served inside you application folder. See docs on using static files.

Peter Knego
  • 79,991
  • 11
  • 123
  • 154
0

You don't need a FileServlet to serve static content. Instead, declare the files that intend to be static, and App Engine will manage serving them. If for some reason you need to read a file programatically, then declare it to be a resource.

See https://developers.google.com/appengine/docs/java/config/appconfig#Static_Files_and_Resource_Files

Dave W. Smith
  • 24,318
  • 4
  • 40
  • 46
  • well this seems to be the solution for me..upload static contents directly without any issue, while upload (_programatically create_) contents as resources? – Asif Apr 22 '12 at 07:39
  • That depends on the timing of the upload. If you have data that's convenient to bundle into the war, you can either do that or separately upload it into the Datastore or Blobstore. For example, upload `.properties` files with the war, but if you have data that has its own lifecycles, say something like `zipcode.dat`, you might want to "upload" it programmatically via some admin-only URL. – Dave W. Smith Apr 22 '12 at 17:10