PrintWriter out=reponse.getOutputStream()
out.print()

解决方案 »

  1.   

    out不是可以直接用吗?干吗那么麻烦?
      

  2.   

    ======================================================
    test.jsp
    ------------------------------------------------------<%@ page contentType="text/html;charset=gb2312" %>
    <body>  
    <%!
    int a(int i){
    i=i++;
    PrintWriter out=reponse.getOutputStream();
    out.print(i);
    }
    %>
    <%
    for(int k=0;k<=10;k++){
    a(k);
    }
    %>
    </body>======================================================
    Exception message 
    ------------------------------------------------------
    type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: -1 in the jsp file: nullGenerated servlet error:
        [javac] Compiling 1 source fileC:\tomcat\webapps\ROOT\MyFirst\work\org\apache\jsp\test_jsp.java:13: cannot resolve symbol
    symbol  : class PrintWriter 
    location: class org.apache.jsp.test_jsp
    PrintWriter out=reponse.getOutputStream();
            ^
    C:\tomcat\webapps\ROOT\MyFirst\work\org\apache\jsp\test_jsp.java:13: cannot resolve symbol
    symbol  : variable reponse 
    location: class org.apache.jsp.test_jsp
    PrintWriter out=reponse.getOutputStream();
                            ^
    2 errors
      

  3.   

    晕,在jsp里面你怎么不直接用out来打印呢?
    <%@ page contentType="text/html;charset=gb2312" %>
    <body>  
    <%!
    int a(int i){
    i=i++;
    //PrintWriter out=reponse.getOutputStream();
    out.print(i);
    }
    %>
    <%
    for(int k=0;k<=10;k++){
    a(k);
    }
    %>
    </body>
      

  4.   

    PrintWriter out=reponse.getOutputStream();
    out.print();
    通常是这样的,其他的你自己加吧。
    最好能看看你自己定义的函数是怎么写的。
      

  5.   

    其实我好晕,
    我上面response拼错了,然后楼主也这么用了
    呵呵
      

  6.   

    回 jFresH_MaN(TM):
    谢谢先!如果是在JSP的自定义函数中,out.print()是不行的.
    回AHUA1001(99) :
    谢谢先!用这种方法好象不行,请看我在6楼的贴子.
      

  7.   

    jFresH_MaN(TM):
    还是不行啊
      

  8.   

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

  9.   

    在ECLIPSE中显示“不能解析response”