tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: How to serialize to specific location?
Date Wed, 03 Jan 2001 20:33:54 GMT
Todd Chaffee wrote:

> I have a bean (used in a JSP) that serializes itself once the user submits
> a form.  When the bean serializes itself, it uses a simple file name with
> no path.
> The serialized bean is getting saved in /opt/tomcat/ even though I am
> running in a context that has a base path of /www/mybiz/webapps/.  Any idea
> why it is ending up in /opt/tomcat/ ?

File I/O is an operating system thing, and has no clue what a web app is.
Therefore, it just wrote the file in the current working directory of the Tomcat

>  What is the best way to have the
> bean saved in the path of my context without using a hard-coded path
> name?  More to the point, any suggestions on where it really should be
> saved?  I was trying for the same directory in which the bean lives (i.e.
> /www/mybiz/webapps/examples/WEB-INF/classes/show ) but I'm not sure if that
> is really the best place to store the serialized bean.

That's probably as reasonable as any, although it limits you to running in
servlet containers (like Tomcat) that always expand a WAR file into an unpacked
directory structure.

You can calculate the pathname of the file to store your bean in like this:

    String path =

> Any help is appreciated.
> - Todd Chaffee

Craig McClanahan

View raw message