| Author |
getRealPath() returning null
|
Anjali S Sharma
Ranch Hand
Joined: Jun 29, 2005
Posts: 279
|
|
I have Tomcat installed in Windows XP. In my web application deployed in tomcat, I have the following code line in my action class
String strFilePath = getPageContext().getServletContext().getRealPath(File.separator);
this gives me the value
C:\cvs_repo\Documentum\webtop\src\
Now this same application I have deployed on Weblogic (hosted on windows 2003 server). On this server, the above code line returns null
Now this same application is deployed on Weblogic (hosted on AIX box). On this machine this code line returns the correct file path.
Can somone please let me know why it is returning null on windows 2003 Weblogic.
Thank you
|
 |
ujjwal soni
Ranch Hand
Joined: Mar 28, 2007
Posts: 391
|
|
Hi,
While giving the parameter for getRealPath().. try giving the parameter including your context path.
For eg: if your context path is /TestContext
try using
Basically getRealPath is not defined for applications deployed in a WAR file, and indeed works differently between different application servers (Tomcat and WebLogic for example).
In WebLogic, getRealPath returns null for WAR files.
See this discussion for ways around this limitation: http://www.experts-exchange.com/Web/Application_Servers/Weblogic/Q_21004006.html
|
Cheers!!!
Ujjwal B Soni <baroda, gujarat, india> <+919909981973>
"Helping hands are better than praying lips......"
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56549
|
|
ujjwal soni wrote: try giving the parameter including your context path.
No, the context path is never required.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Anjali S Sharma wrote:
String strFilePath = getPageContext().getServletContext().getRealPath(File.separator);
[sorry if i dont know]from where you get the method (getPageContext()) ?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56549
|
|
|
PageContext is only available within JSP pages and is not a part of Servlets.
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
thanks bear
|
 |
Anjali S Sharma
Ranch Hand
Joined: Jun 29, 2005
Posts: 279
|
|
Bear Bibeault wrote:PageContext is only available within JSP pages and is not a part of Servlets.
getPageContext() is provided by the framework (Documentum) that we are using.
so, getPageContext() returns a valid object.
getPageContext().getServletContext() returns a valid object. Only getPageContext().getServletContext().getRealPath(File.separator) returns null in some of the conditions (as mentioned in the initial post)
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56549
|
|
Anjali S Sharma wrote:
Bear Bibeault wrote:PageContext is only available within JSP pages and is not a part of Servlets.
getPageContext() is provided by the framework (Documentum) that we are using.
Don't you think that was relevant information to provide from the start? How are we to know what proprietary system provide or not (especially when they foolishly name things in conflict with standard elements)?
|
 |
 |
|
|
subject: getRealPath() returning null
|
|
|