Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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 The Software Craftsman this week in the Agile 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: 62298

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] [Bear's FrontMan] [About Bear] [Books by Bear]
Have you tried LearnNowOnline?
subject: ServletContext.getRealPath