out是jsp的内置对象你在方法中调用是不可以的只能在页面种调用

解决方案 »

  1.   

    out是implicit object,不能在<%! %>里使用。
      

  2.   

    那么要在函数里调用JSP的内置对象,有没有办法实现的呢?
      

  3.   

    out是JSP的内定义对象,要在函数中调得通过javax.servlet.jsp.JspWriter或PrintWriter:/****************************************************************/
    /* Function Name : bReadFile */
    /* Function Para : File pfileRead */
    /*        PrintWriter ppwOut */
    /* Function Func : Read file */
    /****************************************************************/
    private boolean bReadFile(File pfileRead, PrintWriter ppwOut)
    {
    String   strRead;
    long      lCurPointer = 0 ;
    long  lFileLength;
    byte     buffer[] = new byte[1024];
    boolean  blnRet = false; //Use RandomAccessFile to read file
    try
    {
    RandomAccessFile fileRead = new RandomAccessFile(pfileRead,"r");
    lFileLength = pfileRead.length();
    ppwOut.println("File Content:<br>");
    while(lCurPointer < lFileLength)
    {
    strRead = fileRead.readLine();
               ppwOut.println(strRead);
    ppwOut.println("<br>");
    lCurPointer = fileRead.getFilePointer();
    }
    fileRead.close();
    }
    catch(Exception e)
    {
    String err = e.toString();
    //out.println(err);
    return blnRet;
    } blnRet = true;
    return blnRet;}
      

  4.   

    那我该怎么调用这样的方法呀,这个PrintWriter ppwOut的实参应该用什么呢???