jQuery in Action, 3rd edition
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 code.....in 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 agree. Here's the link: http://aspose.com/file-tools
subject: problem with getRealPath
It's not a secret anymore!