Solved

Need help with file input/output from servlet

Posted on 2006-11-05
2
214 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
copyEndy  challenge 15 55
Books that can get me started on JAVA 2 54
strDist challenge 35 84
Free Alternative to JIRA 4 58
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This video teaches viewers about errors in exception handling.

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now