I am working on web application.I invoke on my jsp request.getContextPath()
, but strangely I got address /streetshop
.
Then I am appending some
You mix things up here. HttpServletRequest.getContextPath()
returns your web application root path. In your example this is /streetshop
, so your URL may look similar to www.myapp.com/streetshop
. If you want to access the internal file system path, you must obtain it from the ServletContext
using request.getServletContext().getRealPath("/"). This should return the location of your WAR files' WebContent
folder.
Keep in mind that if you modify contents of this path during runtime, you're going to loose everything when redeploying your application.