Solved

Need help with file input/output from servlet

Posted on 2006-11-05
2
230 Views
Last Modified: 2013-11-24
I have a servlet that I'm trying to read from a file and write it back out with new objects added to it, but the the servlet can not find the file.  It's running on Tomcat so i'm almost sure it has to do with the catalina.policy file.

I believe that i need to do something similar to the following but i'm not sure if it is correct and if it is where do i need to place it in the catalina.policy file.  Also, would i need to remove anything from the catalina.policy file?

grant codeBase "file:${catalina.home}/webapps/ROOT/conf" {
      permission java.io.FilePermission "${catalina.home}/webapps/ROOT/conf  myfile.txt", "read,write,delete";
};

Or do you guys have any other ideas as to why it may not be able to find the file?
0
Comment
Question by:tbboyett
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 17879271
whats the error?
more likely that it can't find the file than a security exception. Why are u using a security manager?

If its not finding the file try using the ServlketContext getRealPath() method toi get the file path
0
 
LVL 5

Author Comment

by:tbboyett
ID: 17884648
as usual you are correct objects, thanks once again :D
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java Server Faces parameter pass? 6 48
eclipse shortcuts 9 54
type mismatch (Object[] to double[] 4 24
eclipse buid path vs tomcat lib path 10 22
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question