This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
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 Make it so: Java DB Connections & Transactions this week in the JDBC forum!
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: 63552

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!