views:

40

answers:

1

I want to get the real path of a file in java by using the request method getRealPath()but it is deprecated now i want an alternate to it i tried get servletcontext but it is not returning the whole path

in jsp page when i m using application.getRealPath("/") it is giving whole path as D:/.....

but in java servlet code i m not getting this method working so i want a perfect httprequest method which will be returning whole path of the application.

please suggest me a perfect method with example if possible

+2  A: 

request.getServletContext().getRealPath(..) (or if you are within a servlet, just call getServletContext().getRealPath(..)

Bozho
i am using struts 1 in this i had tried this earlier request.getServletContext is not defined giving error
krishna
_what_ error? (it's called exception)
Bozho