access denied :(

I created a single jsp page that is just supposed to create a new jsp

file in the current directory. I put together this code (see below),

this code will always put the file in the "bin" directory...

Disallowing me to access it again with my application.

I would like it to create the file in the Same directory as the jsp

page... but its not working.

There seems to be an a write access violation, is there anyway to get around this? Or simply sign a jsp page to allow it to create files? Dam this is frustrating... Or perhaps I just need another low budget web host that will allow me to do it?! Any suggestions?

If you copy and paste this into a jsp page, and run it... you might

see my problem in action.

Thanks in advance!

<%@page import="java.io.*"%>

<%

String curDir = System.getProperty("user.dir");

File filFile = new File(curDir + "/pleaseWork.txt");

////////breaks on the next line/////////////////////////

boolean success = filFile.createNewFile();

if (success){

out.print("created new file" + curDir + "/pleaseWork.txt");

}else{

out.print("updated file" + curDir + "/pleaseWork.txt");

}

%>

[1264 byte] By [adamorna] at [2007-10-3 3:18:51]
# 1

I don't think that creating JSPs on the fly is really a good idea. Why not just skip that step and generate the output that the JSP would have generated?

However if you must do that, don't put it in the current working directory. You've already found out that isn't the right place for it. Although you seem to be in denial about that and seem to want to blame security or something. The JSPs don't go there, so don't try putting them there. There's a servlet context method that gets you the path of the web application.

DrClapa at 2007-7-14 21:10:40 > top of Java-index,Java Essentials,Java Programming...
# 2
ok, Im going to look into the servlet context, and Ill post when I've determined if it will work...but Im actually creating a .txt file, not a jsp file. sorry!
adamorna at 2007-7-14 21:10:41 > top of Java-index,Java Essentials,Java Programming...
# 3
I've worked on projects where the "solution" was for server side functionality (not deployments) wrote files under the document root, and it was always a tremendous pain to maintain.Write them somewhere else. Or see if you can get by without creating files at all.
paulcwa at 2007-7-14 21:10:41 > top of Java-index,Java Essentials,Java Programming...