HTTP Status 500 - --------------------------------------------------------------------------------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 fileD:\Tomcat 4.1\work\Standalone\localhost\jsp\myfunc_jsp.java:16: cannot resolve symbol
symbol  : class PrintWriter 
location: class org.apache.jsp.myfunc_jsp
PrintWriter out=response.getWriter();
        ^
1 error

解决方案 »

  1.   

    jsp页面引用PrintWriter类,但没有引入 cannot resolve symbol
    symbol  : class PrintWriter
      

  2.   

    Unable to compile class for JSP
    symbol  : class PrintWriter 
    location: class org.apache.jsp.myfunc_jsp
    PrintWriter out=response.getWriter();
            ^
      

  3.   

    谢谢,我在页面加了一行:<%@ page import="java.io.PrintWriter"%>,可是运行的时候,出来的是乱码,怎么回事儿呢?文件内容如下:
    <%--
    功能:JSP例程-在JSP中定义函数
    --%>
    <%@ page contentType="text/html;GBK"%>
    <%@ page import="java.io.PrintWriter"%>
    <%! 
    //这一段程序用来将字符串s以波浪形输出,response对象传递进入方法以做输出
    public void WaveText(String s,HttpServletResponse response) throws java.io.IOException{
    int j=0;
    boolean up=true;
    response.setContentType("text/html;GBK");
    PrintWriter out=response.getWriter();
    for (int i=0;i<s.length();i++){
    if (j<0){
    j=0;
    up=true;
    }
    if (j==7){
    up=false;
    }
    out.println("<font size="+j+">"+GBK2UNI(s.substring(i,i+1))+"</font>");
    if (up) j++;
    else j--;
    }
    }
    //这一段代码将GBK字符集转为Unicode
    public String GBK2UNI(String s){
    try{
    String temp=new String(s.getBytes("GBK"),"ISO8859_1");
    return temp;
    }
    catch(java.io.UnsupportedEncodingException e){
    return "sorry";
    }
    }
    //这一段代码将Unicode转为GBK
    public String UNI2GBK(String s){
    try{
    String temp=new String(s.getBytes("ISO8859_1"),"GBK");
    return temp;
    }
    catch(java.io.UnsupportedEncodingException e){
    return "sorry";
    }
    }
    %>
    <html>
    <head>
    <title>JSP例程-在JSP中定义函数</title>
    </head>
    <body>
    <% WaveText(UNI2GBK("这是波浪形的文字,大家快来看呀,走过路过不要错过"),response); %>
    <% WaveText(UNI2GBK("这句话也是波浪形文字,大家来看看啊"),response); %>
    </body>
    </html>
      

  4.   

    <%@ page contentType="text/html;GBK"%>
    有错,改成
    <%@ page contentType="text/html; charset=GBK"%>
      

  5.   

    改成<%@ page contentType="text/html; charset=GBK"%>,运行结果还是没有出来汉字,显示了一些问号........还有哪里不对的吗?
      

  6.   

    在<head></head>之间再加<meta http-equiv="Content-Type" content="text/html; charset=GBK">试试