为什么在WEB下就不能生成.txt文件??郁闷!!

soft1999 2006-03-20 01:38:37
这是我本地的测试代码,没有问题.可以创建文件.并且写入文字
public class test
{
OP_File o=new OP_File();
public void show()
{
o.writefile("log/aaa.txt","\n数据库完成于",true);
}
public static void main(String args[]){
test t=new test();
t.show();
o=null;
}
}
但是我做到servlet里面就行啊.为什么??看下我的代码:
public class test extends HttpServlet {
OP_File o= new OP_File();
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>IVR PUSH</title>");
out.println("</head>");
out.println("<body>");
o.writefile("log/aaa.txt","\n数据库完成于",true);
out.println
("</body>");
out.println("</html>");
out.close();
o=null;
}

什么提示也没有,就是生成不了..为什么啊??
...全文
89 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
soft1999 2006-03-20
  • 打赏
  • 举报
回复
是不是因为servlet是客户端调用的的啊???

我又测试了下,这次用的ServletContextListener类写文件.注册好了兼听.这次应该是服务器了吧..可是仍然不行.

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧