1

I have the following folder structure

TempProj
!-js
!-jsp
!-WEB-INF
  !-classes
  !-lib

Inside my lib folder, I have a java file that creates an XML file, I actually need the file to be generated inside the jsp folder.

I'm creating using StreamResult result = new StreamResult("test.xml");

I've tried giving the following paths "../../jsp/text.xml". Since I've deployed it, the path has to be relative.

Any help!!

0

1 Answer 1

0

What App Server you using ? If you are using Websphere (possibly others, but I don't know) , you might have to set up a 'file url' and use JNDI to delegate the job of finding the directory to the App Server itself.

As an experiment to shed more light on the problem, you could try something like:

File nopath = new File("text.xml");
System.out.println(nopath.getCanonicalPath());

And:

File relpath = new File("../../jsp/text.xml");
System.out.println(relpath.getCanonicalPath());

I wonder if you are going to be able to do this...I have a feeling (and that's all it is , please check!) that App Server's Security manager might not like you trying to traverse up and out of the directory....

You might want to reconsider not creating a file-on-disk - instead create a new servlet that dynamically serves up the XML...(presuming that you need the client-browser to see some XML ultimately...).

3
  • It wasn't actually me. I just edited a technical mistake in the second variant. But as the post is incorrectly marked as "community wiki", the original author does not appear.
    – Bozho
    Dec 29, 2009 at 18:33
  • I set this to community wiki 'cos I thought this would be the best way of allowing edits...I may need to consult the stackoverflow help on this though :-) Glad you got this working.
    – monojohnny
    Dec 30, 2009 at 9:36
  • 1
    Non-CW posts are also editable by others with enough reps.
    – BalusC
    Dec 30, 2009 at 11:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.