Re: J2EE and File

From: Christopher Blunck (blunck_at_gst.com)
Date: 10/22/03


Date: Wed, 22 Oct 2003 00:20:36 -0400

On Sun, 19 Oct 2003 09:35:17 -0700, Murat G. wrote:

> Hello,
> I am not an experienced J2EE developer, so please forgive me if this
> question seems silly...
> Does J2EE spec restrict/prohibit local file operations? Is it possible
> to use java.io package from within a J2EE application, to read/write
> local files on the app server? Is there a standard way of doing it?
> Thanks in advance,
> Murat

Hi Murat-

I'm not sure if J2EE explicitly forbids it, but writing files to the local
machine within a J2EE environment is not a best practice. J2EE is
engineered as an enterprise level distributed component archictecture,
allowing you to easily scale your application to multiple platforms
without making significant code changes. Indeed, that's partially why
EAR/WAR was conceived - the ability to package your application in a
standards compliant fashion frees the developer from the platform specific
limitations of file i/o. It also makes applications more portable, and
easier to deploy in new environments (application servers).

Let's say you take your portable J2EE application and introduce code that
writes configuration information to a local file. What then happens when
you wish to scale your application to two servers? What will you do when
a request arrives at server A that triggers an update to a local file.
How will B know of the update? It won't, at least not unless A tells B
about it. And that architecture does not scale.

A best practice imo is to use the database to store configuration
information, or any type of property that may need to be accessed across
platforms. Alternatively, cluster your J2EE environment. Either way, do
it in a platform independant fashion and make as little use of the
filesystem as possible.

-c



Relevant Pages

  • J2EE and File
    ... Does J2EE spec restrict/prohibit local file operations? ...
    (comp.lang.java.developer)
  • Re: Beginning J2EE
    ... Sun's App Server, based on the open-source Glassfish, is full featured. ... I started my JEE (then "J2EE") learning on Tomcat, ...
    (comp.lang.java.programmer)
  • Re: What really is J2EE? JBoss? Tomcat?
    ... Tomcat is a servlet/jsp engine, ... server is the playground for this.. ... JBoss is an example of a J2EE container. ...
    (comp.lang.java.developer)
  • Re: What is an application server?
    ... >> Now web servers run business logic via servlets and EJBs, ... >> server unless you want to isolate business logic from web services. ... http://java.sun.com/j2ee/ describes the J2EE platform. ... web container and the EJB container. ...
    (comp.sys.sun.admin)
  • Re: OpenVMS Clustering Question
    ... It's been awhile since I worked with OpenVMS clustering. ... The J2EE applications server tier can provide exactly this ... server tier replicates state across the app tier servers. ...
    (comp.os.vms)