getRealPath()

M

Manish Hatwalne

The documentation of -
public java.lang.String getRealPath(java.lang.String path)
of ServletContext says -

<quote>
The real path returned will be in a form appropriate to the computer and
operating system on which the servlet container is running, including the
proper path separators. This method returns null if the servlet container
cannot translate the virtual path to a real path for any reason (such as
when the content is being made available from a .war archive).
</quote>

What would be the workaround in this case? I need to deploy my application
as a war file and I also need to get the real path of a web document.

I can store the path in the web.xml file, but want to avaoid it as long as
it is possible. Is there any other way of doing this?

TIA,
- Manish
 
C

Chris Smith

Manish said:
The documentation of -
public java.lang.String getRealPath(java.lang.String path)
of ServletContext says -

<quote>
The real path returned will be in a form appropriate to the computer and
operating system on which the servlet container is running, including the
proper path separators. This method returns null if the servlet container
cannot translate the virtual path to a real path for any reason (such as
when the content is being made available from a .war archive).
</quote>

What would be the workaround in this case? I need to deploy my application
as a war file and I also need to get the real path of a web document.

You seem to have missed something... there's a reason that getRealPath
returns null in that context: If you deploy your web application as a
war file, there IS no real path for any of your web app resources,
because there's no file corresponding to any resource. They are all in
the war file. You're essentially saying "I need a house with no
windows, but I also need the ability to open a window."

So since the question you asked is inherently without meaning, what is
your real requirement?

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top