• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
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();
sm.checkWrite("/server1/home/user98/webapp/cw2/rssoutput.html");
However, when I try to write to it using TransformFactory I either get a "java.io.FileNotFoundException: /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:
"java.security.AccessControlException: access denied (java.io.FilePermission /cw2/rssoutput.html write)"
The transformation code is:
out.println(doTransform(strSelectedFeedLocation));
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.
 
If you are using a wood chipper, you are doing it wrong. Even on this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic