This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv 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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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.
It is sorta covered in the JavaRanch Style Guide.
subject: problem with getRealPath
It's not a secret anymore!