This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Servlets and the fly likes problem with getRealPath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Servlets
Bookmark "problem with getRealPath" Watch "problem with getRealPath" New topic

problem with getRealPath

Janardhan Mudduluru

Joined: Jul 09, 2009
Posts: 4

I am using getRealPath in my application which is deployed in application server as war file.

getRealPath is returning null,So i am trying to use getResource here in lieu of getRealPath.

suggest me whether it is a correct approach or not?

and also is there any method to convert URL to String type.

Need Urgently.....

your Response will be much appreciated.

Thanks in advance.

Deepak Bala

Joined: Feb 24, 2006
Posts: 6662

The javadoc has a hint for your problem.

Let us know what you are trying to do. That will help us answer your question better

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
bhaskarvignesh chandra sekaran

Joined: Jun 27, 2009
Posts: 17

Try this piece of code

request.getContextPath()+"/xxx/public_html/ YOUR CONTEXT DIR HERE");

SCJP, SCWCD,preparing for SCDJWS
View my facebook profile
Janardhan Mudduluru

Joined: Jul 09, 2009
Posts: 4
Thanks Deepak and chandra for your quick responses....

i have solved this issue by removing getRealPath from my lieu i did use getResourceAsStream method directly without invoving getRealPath mehtod in between.

I am using this code in FrameWorkManager plugin provided by struts.

Thanks again

yours Janardhan.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: problem with getRealPath
jQuery in Action, 3rd edition