Thanks for the suggestions.  Your explanations cleared things up 
considerably.  One of your points got me wondering if I'm heading down the 
wrong path here.  Please see my note in the original thread below.

Thanks,
Todd Chaffee

At 12:33 PM 01/03/01 -0800, you wrote:
>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
>process.
>
>
> >  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.


I am serializing to implement persistence.  Considering your point above, 
any suggestions on a 'better' way to do this?  My first thought was a flat 
file and then I realized that serializing the bean would be more portable 
and a more 'java' way of doing it but maybe I'm heading down the wrong path 
altogether.



>You can calculate the pathname of the file to store your bean in like this:
>
>     String path =
>       getServletContext().getRealPath("/WEB-INF/classes/show/MyBean.ser");
>
> >
> > Any help is appreciated.
> >
> > - Todd Chaffee
> >
>
>Craig McClanahan


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to