« FreeRoller running... | Main | Leo is 5 months old. »

File access from Servlet apps.

<a href= "http://freeroller.net/page/jduska/20021125#managing_files_within_a_web">Jeff Duska is forgetting a couple of things that many Servlet/JSP developers (myself included) often forget. He is forgetting the distributed nature of Servlet apps and he is forgetting the WAR.

Someday, when your app becomes incredibly popular, you might find that you need to distribute the load across multiple worker processes on multiple computers. All the major app servers support this, does your app? In a distributed configuration, if your app writes a file to the file-system on one computer, you won't be able to get to that file on another computer. If you want all instances of your app to share a file, then this is a problem. If you are just writing a simple little temporary file, which sounds like Jeff's case, then this is generally not a problem.

Even if you are only writing a temporary file, you still don't want to write it inside your Servlet context. When your app is packaged in a WAR file, may not be able to open files inside the Servlet context. If you are just writing a temporary file, it might be better to use one of the static <a href= "http://java.sun.com/j2se/1.4/docs/api/java/io/File.html">java.io.File.createTempFile() methods to get a file.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed

« FreeRoller running... | Main | Leo is 5 months old. »

Welcome

This is just one entry in the weblog Blogging Roller. You may want to visit the main page of the weblog

Related entries

Below are the most recent entries in the category Java, some may be related to this entry.