File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "ServletContext.getRealPath" Watch "ServletContext.getRealPath" New topic


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.

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,

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

Joined: Jan 10, 2002
Posts: 63838

Originally posted by Arockia Raj:
That will fail without quotes for the string.

ServletCOntext.getRealPath is returning null.

It's ServletContext, not ServletCOntext.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: ServletContext.getRealPath
It's not a secret anymore!