You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by egan0019 <eg...@umn.edu> on 2005/05/27 21:11:48 UTC

[OT]: Adding content/JSPs on the fly: file.separtor

When building file path strings, should one always use the
System.getProperty("file.separator") return value?  Is this to
differentiate between Windows("\") and unix/linux/solaris("/" separators? 
I haven't seen that property before.

And, are there any other things I should know about to make my file system
accessing code portable?

Yes, I am new to java.

On 27 May 2005, Will Hartung wrote:
> I'm scheming on a little project, and one of the things I want to be able
to
> do is simply add content to the application.
> 
> The typical way to add content is also rather static -- add it to the WAR
> and redeploy.
> 
> That's not particularly dynamic tho, and doesn't really facilitate
changing
> content from the web app.
> 
> One of the things I'd like to be able to create on the fly are JSPs that
are
> then served by the container.
> 
> Now, Kenneth Jensen may have answered my question for me by providing
this
> snippet:
> 
> ServletContext context = getServletConfig().getServletContext();
> String slash = System.getProperty("file.separator");
> keystore = context.getRealPath("/") + "WEB-INF" + slash +
> getInitParameter("keystorefile");
> 
> The key being the "getRealPath("/")" code.
> 
> So, my question is do you think that it's reasonable and fairly portable
to
> leverage that technique to find where on the system a webapp is deployed
and
> use that as a base path to create new resources to be served by the
> container?
> 
> I'm aware that it is possible for a web app to be deployed in an
unexploded
> WAR, and I would simply make it a precondition that this not be the case
> (and for 99% of most systems, it simply isn't an issue).
> 
> But, shouldn't this pretty much work with most common servlet containers?
> 
> Thanx for any insight...
> 
> Regards,
> 
> Will Hartung
> (willh@msoft.com)
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: [OT]: Adding content/JSPs on the fly: file.separtor

Posted by Tim Diggins <su...@red56.co.uk>.
Hi -

I think it would be better to use java.io.File.separator (which will be 
identical to file.separator, but is clearer and compile-time checked for 
typos (as opposed to the string "file.separator" )).


Tim

egan0019 wrote:
> When building file path strings, should one always use the
> System.getProperty("file.separator") return value?  Is this to
> differentiate between Windows("\") and unix/linux/solaris("/" separators? 
> I haven't seen that property before.
> 
> And, are there any other things I should know about to make my file system
> accessing code portable?
> 
> Yes, I am new to java.
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org