Hey
Robert Krüger wrote:
> we ran into the following problem: we have tried to get all our j2ee
> aplications independent of the location they are deployed to, even if a
> servlet had to access the local file system (for uploads, getting xsl
> templates etc.) by using the getRealPath method in the servlet api and
> using everything else relative to that. this way we can rsync the entire
> application including all deployment files to different development or
> production servers without a change (only datasources have to be configured
> globally in the ejb server).
<snip>
Ahh, one of my favourite problems. Here's two neat ways to get paths in
Java without hardcoding them:
* Get the location of "this" by doing
this.getClass().getProtectionDomain().getCodeSource().getLocation().
This will give you the location of the class. Do this in the bean to
get the location of the beans class. I know you wanted the servlets
location, but maybe you can use this instead.
* I sometimes place "dummy" files in the classpath and do new
File(getClass().getResource("/dummy.tmp").getFile()).getParent(), which
gives me the directory where the dummy.tmp file has been placed within
the classpath. That way I can move the dummy file and the app will
automatically be "reconfigured" to use the new location.
HopeThisHelps :-)
/Rickard
--
Rickard Öberg
@home: +46 13 177937
Email: [EMAIL PROTECTED]
http://www.dreambean.com
Question reality
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".