你吧文件放到webapps/pdb/web-inf/classes里面直接调用读写就可以了!

解决方案 »

  1.   

    打包web应用的时候,也就是配置.war文件的时候,把文件作为一项资源注册到jndi,这是sun推荐的使用方式,sun不推荐直接用file操作
      

  2.   

    to: ctrlpower(险峰) 
    可以得到输入流,但不知如何输出?to:: badbird(badbird) 
    我的应用只是用JSP,用不上J2EE。
      

  3.   

    JSP的Application对象的getRealPath()方法
    得到服务根路径
    然后用相对路径定位文件就可以了。
      

  4.   

    to:ahbill(阿漂) 
    如果是虚拟主机,我会有读写权限吗?
    而且我不希望用JSP传参数给Java程序。我希望通过Java程序的类文件的路径做定位。
      

  5.   

    试试这样定位类文件:    
        String clsName = this.getClass().getName();
        String resName = "/" + clsName.replace( '.', '/' ) + ".class";
        URL clsURL = this.getClass().getResource( resName );
        if( clsURL != null )
        {
          String clsPath = clsURL.getFile();
          System.out.println( clsPath );
        }