Within a jsp file i'm trying to navigate to load xml file. The location of the JSP file is
/projectFolder/layout/applicationName/index.jsp
the location of the xml file
/projectFolder/data/files/myfile.xml
The location of the project folder is different in each environment, example: in my local pc the location is:
c:\myApps\BPServer\tomcat\webapps\projectFolder
when i use the following code:
<c:set var="xmlfile" value="${pageContext.request.contextPath}/data/files/myfile.xml"/>
The value of xmlFile is set to:
c:\projectFolder\data\files\myfile.xml
However the strange thing is that if i use the xmlfile as href
then the correct path and file is located:
<jsp:attribute name="rightContent"><a href="${xmlfile}">XML FILE</a></jsp:attribute>
Any idea how can i get the correct file path in order to the following to work:
boolean canLocateFile = fileExists(xmlfile);
public static boolean fileExists(String filepath)
{
File f = new File(filepath);
return f.exists();
}