This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes I might just kill myself...Problem with context paths Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "I might just kill myself...Problem with context paths" Watch "I might just kill myself...Problem with context paths" New topic

I might just kill myself...Problem with context paths

Malcolm White

Joined: Nov 10, 2002
Posts: 15
I'm completely baffled by the server paths that I have to use within my servlet. I keep on getting AccessControlExceptions with the flag indicating a "write" exception.
I created a SecurityManager object and it did not throw any exceptions when I checked for write permissions to the file in question:
Object context = null;
SecurityManager sm = System.getSecurityManager();
However, when I try to write to it using TransformFactory I either get a " /server1/home/user98/webapp/cw2/rssoutput.html (Permission denied) " error, or in the case of having the path set to "/cw2/rssoutput.html", which accesses the same location from the webapp context, I get:
" access denied ( /cw2/rssoutput.html write)"
The transformation code is:
public String doTransform(String strInputFile) throws TransformerException,
TransformerConfigurationException,FileNotFoundException, IOException
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new StreamSource("http://my_web_site/user98/webapp/cw2/renderer.xsl"));
transformer.transform(new StreamSource(strInputFile), new StreamResult(new FileOutputStream("/cw2/rssoutput.html")));
return ("<br><br>Transform done!");
I have tried setting permissions on files and folders to 777, but to no avail. As you can see, it works for the StreamSource object since I've set it to an absolute http path, but that doesn't seem to work with my FileOutStream object.
Any pointers? Thanks for your time everyone.
It is sorta covered in the JavaRanch Style Guide.
subject: I might just kill myself...Problem with context paths
Similar Threads
ServletOutputStream.write not working in IE 7
getAssociatedStylesheets failed
Best API to update an XML document!
I'm getting an error about my stylesheet missing the xsl:version attribute
Urgent: simple transformer failing with strange file exception