TOMCAT日志报以上错误。
代码如下<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page language="java" contentType="text/html; charset=GBK" import="">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title></title>
<link href="/style/css.css" rel="stylesheet" type="text/css">
</head>
<%
     String id = request.getParameter("id")==null?"":request.getParameter("id").trim();
     for(int i=0;i<id.length();i++){
       String substring=id.substring(i,i+1);
       if(("0123456789").indexOf(substring)==-1){
          out.print("<script language='javascript'>");
          out.print("alert('您要的网页不存在,请与网站管理员联系!');");
          out.print("history.go(-1);");
          out.print("</script>");
          out.close();//是不是我在这里用了关闭才导致那个错误的。
      }
     } 
     CompanyManagerImpl manager = new CompanyManagerImpl();
     CompanyModel model = manager.getCompanyInfoListById(id);
     if(model==null){
          out.print("<script language='javascript'>");
          out.print("alert('您要的网页不存在,请与网站管理员联系!');");
          out.print("history.go(-1);");
          out.print("</script>");
          out.close();
     }
     ShengManagerImpl shengManager = new ShengManagerImpl();
     ShiManagerImpl shiManager = new ShiManagerImpl();
     String shengId=model.getShengId()+"";
     String shiId = model.getShiId()+"";
     String shengName = shengManager.getShengNameById(shengId);
     String shiName = shiManager.getShiNameById(shiId);
%>
<body bgcolor="F4F9FE" leftmargin="0" topmargin="0">
<table width="66%" height="519" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="46" colspan="3"  valign="bottom"><img src="/map/head.gif" width="678" height="46"></td>
  </tr>
  <tr> 

解决方案 »

  1.   

    out.close();//是不是我在这里用了关闭才导致那个错误的。改为 return;out其实是response的一个输入流的操作,用了out。close()
    整个输出流就被关闭了,后面的out都会报错,包括后面的html标签的输出
    其实也是out.println();
    建议楼主看看jsp编译后的java文件就明白了
      

  2.   

              out.close();//是不是我在这里用了关闭才导致那个错误的。
    删掉这个
      

  3.   


    支持,你需要将你的这两句out.close();都改为return;其实更好的办法是将页面的跳转放在Action中,也就是控制层,放在页面中感觉比较乱。
      

  4.   

    哈哈,发财了,都是高手帮我回答问题,还有一个问题是
    我把out.close();
    弄掉,不加return报错。
    有的地方又删除是可以的,加上return反而报错。
    什么原因????
      

  5.   

    从你上面贴的代码来看,加return都不会有错。如果不加则会继续执行下面的out.print(),所以出错。至于加上错了,你把原因贴一下看看,注意返回类型。