接上一页文件gb2312.jsp代码
<%@ page contentType="text/html;charset=GB2312"%>
<%@ page language="java"%>
<html>
<head>
<title>汉字处理</title>
</head>
<body>
<center>
<font size=5 color=blue>汉字处理</font>
</center>
<br>
<hr>
<br>
<certer>
<h3>
<font color=red>
<!--取得InputName文本的输入值-->
<%
String tmpName=ISOtoGb2312.convert(request.getParameter("inputName"));
out.println(tmpName);
%>
</Font>
对大家说:
</center>
<br>
<%
String tmpMsg=ISOtoGb2312.convert(request.getParameter("txtaMsg"));
out.println(tmpMsg);
%>
</font>
</h3>
</body>
</html>

解决方案 »

  1.   

    接上一页
    public class   ISOtoGb2312
    {
    public static String convert(String str) 
    {
    try
    {
    byte[] bytesStr=str.getBytes("ISO-8859-1");
    return new String(bytesStr,"gb2312");
    }
    catch(Exception ex)
    {
    return str;
    }
    }
    }现在我的问题是在提交后出现下面的提示
    An error occurred between lines: 18 and 21 in the jsp file: /jsp100/gb2312.jspGenerated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\localhost\_\jsp100\gb2312$jsp.java:63: Undefined variable or class name: ISOtoGb2312
                     String tmpName=ISOtoGb2312.convert(request.getParameter("inputName"));
                                    ^
    An error occurred between lines: 26 and 29 in the jsp file: /jsp100/gb2312.jspGenerated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\localhost\_\jsp100\gb2312$jsp.java:72: Undefined variable or class name: ISOtoGb2312
                     String tmpMsg=ISOtoGb2312.convert(request.getParameter("txtaMsg"));
                                   ^
    2 errors
      

  2.   

    我在jsp下建立了一个这样的目录:  WEB-INF\classes,将编译好的ISOtoGb2312.class文件放在该目录下,还是不行!
      

  3.   

    你没有把你的类import进来
    在文件头加:
    <%@ page import="ISOtoGb2312"  %>
    创建一个实例:
    ISOtoGb2312 ISOtoGb2312=new ISOtoGb2312();接着你就可以调用bean中的方法了:ISOtoGb2312.convert()......