?
Solved

Need help with file input/output from servlet

Posted on 2006-11-05
2
Medium Priority
?
262 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month16 days, 12 hours left to enroll

862 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