wood burning stoves 2.0*
The moose likes Servlets and the fly likes ServletContext.getRealPath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "ServletContext.getRealPath" Watch "ServletContext.getRealPath" New topic
Author

ServletContext.getRealPath

Arockia Raj
Ranch Hand

Joined: Dec 08, 2006
Posts: 37
I need to access xsl file inside the servlet.The xsl file is available inside the webapplication.I have used the following method for accessing the realpath of the file.
ServletContext.getRealPath(/../filename).

It's working fine in windows environment.When we moved the application to unix environment ServletCOntext.getRealPath is returning null.


Kindly help us in resolving this issue.

Thanks in advance,

regards
ARaj
Shahnawaz Shakil
Ranch Hand

Joined: Aug 04, 2008
Posts: 57
Is the content to which the path is refering is available as part of war file? If it is the case then this method will return null.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

Originally posted by Arockia Raj:
ServletContext.getRealPath(/../filename).
That will fail without quotes for the string.

ServletCOntext.getRealPath is returning null.

It's ServletContext, not ServletCOntext.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ServletContext.getRealPath
 
Similar Threads
log4j: right path for the log file
relative path problem
Path to config file
Apache commons file upload does not work for me.
How to specify the place from file which is going tobe read