wood burning stoves
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 OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP 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: 61973

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]
It is sorta covered in the JavaRanch Style Guide.
subject: ServletContext.getRealPath