lr Kiko

Greenhorn
+ Follow
since Mar 18, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by lr Kiko

I have a similar problem but in windows server 2003..
I would like to schedule a jar file to run which uses IO.
Can someone help?
12 years ago
How to mention the relative path of the file in fileinputstream?

The directory structure is as follows,Inside the **model** folder i have a java file called GetContents.java
I need to refer the input.xls( a file inside the template folder ) in GetContents.java file.

I tried

new FileInputStream("..\\..\\..\\template\\DevContentsTemplate.xls")


cos the GetContents.class file will be inside webcontent\web-inf\classes\model\GetContents.class and I thought if i use the above relative path , it should refer webcontent\web-inf\template\input.xls
But it throws a file not found exception.

Please note that i have configured the tomcat server working directory to point to my current project "CVT"

Kindly help.

Thanks.
15 years ago
I tried 2 approaches

1) i tried to use the following in my action class,
String strPath = request.getSession().getServletContext().getRealPath("");

Following is the value set in strPath
C:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ContentValidation

then i tried ,
String strPath = request.getSession().getServletContext().getRealPath("")+"\\WebContent\\WEB-INF\\template\\initial.xls";

Following is the value set in strPath
C:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ContentValidation\WebContent\WEB-INF\template\initial.xls

It says file not found exception.
'But when i use the aboslute path ,
C:\workspace\ContentValidation\WebContent\WEB-INF\template\input.xls
it works fine

2)
String path = request.getContextPath();
System.out.println(path+"/WebContent/WEB-INF/template/input.xls");
output was
/ContentValidation/WebContent/WEB-INF/template/input.xls

but still i get file not found exception

can someone help please

15 years ago
Hi,

I am having an action class and inside my action class i want to refer to an excel file in the following directory : webContent/WEB-INF/templates/sample.xls.

I am able to access this file if i specify absolute path, but when i give relative path, it gives a FileNotFoundException.

How do i solve this?

Thanks.
15 years ago