我用java+tomcat做的 
从一个jsp网页跳到一个servelet,在跳到一个jsp
用调试的方法在后面那个jsp也运行了,完了是下载的界面,不知道是为什么
可有高手帮忙分析分析,非常感谢

解决方案 »

  1.   

    在jsp里面
    有没有这样的代码?writer = response.getWriter();
    writer.print("");
      

  2.   

    真抱歉,没看懂你的意思!
    servlet里面加上
    response.setContentType("text/html"); 
    看看!你是不是在servlet里面forward了
      

  3.   

    servlet:import java.io.IOException;
    import java.io.PrintWriter;import javax.servlet.ServletException;
    import javax.servlet.http.*;import bean.*;import DAO.*;public class updataOperator extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    Operator oper= new Operator();
    DAOFactory df = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
    OperatorDAO odao= df.getOperatorDAO();
    System.out.println(request.getParameter("B1"));
    if(request.getParameter("B1")==null){
    String str=request.getParameter("operatorId");
    System.out.println(str);

    oper.setOperator_ID(str);
    oper=odao.getSelect(oper);
    // System.out.println(oper.getOperator_Name());
    request.getSession().setAttribute("oper", oper);
    // request.getRequestDispatcher("./updataOperator.jsp").forward(request, response);
    response.sendRedirect("updataOperatorjsp.jsp");
    }else {
    if(request.getParameter("B1").equals("修改")){
    oper.setIs_Admin(request.getParameter("R1"));
    oper.setOperator_ID(request.getParameter("ID"));
    oper.setOperator_Name(request.getParameter("NAME"));
    oper.setOperatot_Pwd(request.getParameter("PWD"));
    odao.update(oper);
    response.sendRedirect("Operator.jsp");
    }
    if(request.getParameter("B1").equals("删除")){
    oper.setOperator_ID(request.getParameter("ID"));
    odao.delete(oper);
    response.sendRedirect("Operator.jsp");
    }
    }
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    doGet(request, response);
    }}
      

  4.   

    jsp:
    <%@ page language="java"  contentType="text/html; charset=GB2312"%>
    <% request.setCharacterEncoding("GB2312"); 
    response.setContentType("GB2312");%>
    <%@ page import="bean.*" %>
    <HTML><HEAD><TITLE>------</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=GB2312">
    <META content="MSHTML 6.00.2600.0" name=GENERATOR>
    <link href="style.css" rel="stylesheet" type="text/css">
    </HEAD>
    <BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
    <CENTER>
    <TABLE cellSpacing=0 cellPadding=0 width=749 border=0>
      <TBODY>
      <TR>
        <TD width=173><A href="http://www.chinamobile.com/index.asp"><IMG 
          height=74 src="images/logo.gif" width=173 border=0></A></TD>
        <TD vAlign=top align=right>
          <TABLE width="100%" border=0 cellPadding=0 cellSpacing=0>
            <TBODY>
            <TR bgColor=#2650a6>
              <TD height="12"><img src="images/spacer.gif" width="1" height="1"></TD>
              <TD height="12"><img src="images/spacer.gif" width="1" height="1"></TD>
              <TD height="12"><img src="images/spacer.gif" width="1" height="1"></TD>
              <TD height="12"><img src="images/spacer.gif" width="1" height="1"></TD>
              <TD height="12"><img src="images/spacer.gif" width="1" height="1"></TD>
            </TR>
            <TR bgColor=#FFFFFF>
              <TD><img src="images/spacer.gif" width="1" height="1"></TD>
              <TD><img src="images/spacer.gif" width="1" height="1"></TD>
              <TD><img src="images/spacer.gif" width="1" height="1"></TD>
              <TD><img src="images/spacer.gif" width="1" height="1"></TD>
              <TD><img src="images/spacer.gif" width="1" height="1"></TD>
            </TR>
            <TR>
              <TD><img src="images/pic01.gif" width="115" height="55"></TD>
              <TD><img src="images/pic04.gif" width="115" height="55"></TD>
              <TD><img src="images/pic03.gif" width="115" height="55"></TD>
              <TD><img src="images/pic02.gif" width="115" height="55"></TD>
              <TD><img src="images/pic05.gif" width="115" height="55"></TD>
            </TR></TBODY></TABLE></TD></TR>
      <TR>
        <TD height="12" colSpan=2 align=right bgColor=#d4dced>
               <img src="images/spacer.gif" width="1" height="1">
          <TABLE cellSpacing=0 cellPadding=0 border=0>
            <TBODY>
            <TR>
              </TR>
              </TBODY>
              </TABLE>
     
        </TD></TR>
      <TR>
      <TD colSpan=2><IMG height=2 src="images\blank(1).gif" width=1></TD></TR></TBODY></TABLE>
      

  5.   

    +上面的jsp:
    jsp:
    <%@ page language="java"  contentType="text/html; charset=GB2312"%>
    <% request.setCharacterEncoding("GB2312"); 
    response.setContentType("GB2312");%>
    <%@ page import="bean.*" %>
    <HTML><HEAD><TITLE>------</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=GB2312">
    <META content="MSHTML 6.00.2600.0" name=GENERATOR>
    <link href="style.css" rel="stylesheet" type="text/css">
    </HEAD>
    <BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
    <CENTER>
    <TABLE cellSpacing=0 cellPadding=0 width=749 border=0>
      <TBODY>
      <TR>
        <TD width=173><A href="http://www.chinamobile.com/index.asp"><IMG 
          height=74 src="images/logo.gif" width=173 border=0></A></TD>
        <TD vAlign=top align=right>
          <TABLE width="100%" border=0 cellPadding=0 cellSpacing=0>
            <TBODY>
            <TR bgColor=#2650a6>
              <TD height="12"><img src="images/spacer.gif" width="1" height="1"></TD>
              <TD height="12"><img src="images/spacer.gif" width="1" height="1"></TD>
              <TD height="12"><img src="images/spacer.gif" width="1" height="1"></TD>
              <TD height="12"><img src="images/spacer.gif" width="1" height="1"></TD>
              <TD height="12"><img src="images/spacer.gif" width="1" height="1"></TD>
            </TR>
            <TR bgColor=#FFFFFF>
              <TD><img src="images/spacer.gif" width="1" height="1"></TD>
              <TD><img src="images/spacer.gif" width="1" height="1"></TD>
              <TD><img src="images/spacer.gif" width="1" height="1"></TD>
              <TD><img src="images/spacer.gif" width="1" height="1"></TD>
              <TD><img src="images/spacer.gif" width="1" height="1"></TD>
            </TR>
            <TR>
              <TD><img src="images/pic01.gif" width="115" height="55"></TD>
              <TD><img src="images/pic04.gif" width="115" height="55"></TD>
              <TD><img src="images/pic03.gif" width="115" height="55"></TD>
              <TD><img src="images/pic02.gif" width="115" height="55"></TD>
              <TD><img src="images/pic05.gif" width="115" height="55"></TD>
            </TR></TBODY></TABLE></TD></TR>
      <TR>
        <TD height="12" colSpan=2 align=right bgColor=#d4dced>
               <img src="images/spacer.gif" width="1" height="1">
          <TABLE cellSpacing=0 cellPadding=0 border=0>
            <TBODY>
            <TR>
              </TR>
              </TBODY>
              </TABLE>
     
        </TD></TR>
      <TR>
      <TD colSpan=2><IMG height=2 src="images\blank(1).gif" width=1></TD></TR></TBODY></TABLE>
      

  6.   


    <TABLE cellSpacing=0 cellPadding=0 width=749 border=0>
      <TBODY>
      <TR vAlign=top>
        <TD width=173 bgColor=#c9d3e9 rowSpan=2>
          <TABLE cellSpacing=0 cellPadding=0 width=173 border=0>
            <TBODY>
            <TR>
              <TD width=11 height="29" bgColor=#2650a6><IMG height=1 
                src="images/blank.gif" width=1 border=0><img src="images/Arrow1.gif" width="23" height="23"></TD>
              <TD width=165 height="29" bgColor=#7691c7>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A 
                class=nav 
                href="<%if(request.getSession().getAttribute("Is_Admin").equals("y")){out.print("modOperator.jsp");}
                else{out.print("Operator.jsp");} %>">新增操作员</A></TD>
            </TR>
            <TR>
              <TD bgColor=#ffffff colSpan=2><IMG height=1 
                src="images/blank.gif" width=1 border=0></TD></TR>
            <TR>
              <TD width=11 bgColor=#2650a6><IMG height=1 
                src="images/blank.gif" width=1 border=0><img src="images/Arrow1.gif" width="23" height="23"></TD>
              <TD width=165 height="29" bgColor=#7691c7>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A 
                class=nav 
                href="<%if(request.getSession().getAttribute("Is_Admin").equals("y")){out.print("Modifyservlet");}
                else{out.print("Operator.jsp");} %>">修改操作员</A></TD>
            </TR>
            <TR>
              <TD bgColor=#ffffff colSpan=2><IMG height=1 
                src="images/blank.gif" width=1 border=0></TD>
            </TR>
            <tr>
              <TD width=11 bgColor=#2650a6><IMG height=1 
                src="images/blank.gif" width=1 border=0><img src="images/Arrow1.gif" width="23" height="23"></TD>
              <TD width=165 height="29" bgColor=#7691c7>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A 
                class=nav 
                href="<%if(request.getSession().getAttribute("Is_Admin").equals("y")){out.print("Resource.jsp");}
                else{out.print("Operator.jsp");} %>">资源管理</A></TD>
            </TR>
            <TR>
              <TD bgColor=#ffffff colSpan=2><IMG height=1 
                src="images/blank.gif" width=1 border=0></TD></TR>
            <TR>
              <TD width=11 bgColor=#2650a6><IMG height=1 
                src="images/blank.gif" width=1 border=0><img src="images/Arrow1.gif" width="23" height="23"></TD>
              <TD width=165 height="29" bgColor=#7691c7>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A 
                class=nav 
                href="<%if(request.getSession().getAttribute("Is_Admin").equals("y")){out.print("Charge.jsp");}
                else{out.print("Operator.jsp");} %>">配置业务费用</A></TD>
            </TR>
            <TR>
              <TD bgColor=#ffffff colSpan=2><IMG height=1 
                src="images/blank.gif" width=1 border=0></TD></TR>
            <TR>
              <TD width=11 bgColor=#2650a6><IMG height=1 
                src="images/blank.gif" width=1 border=0><img src="images/Arrow1.gif" width="23" height="23"></TD>
              <TD width=165 height="29" bgColor=#7691c7>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A 
                class=nav 
                href="newCustomer.jsp">开户</A></TD>
            </TR>
            <TR>
              <TD bgColor=#ffffff colSpan=2><IMG height=1 
                src="images/blank.gif" width=1 border=0></TD></TR>
            <TR>
              <TD width=11 bgColor=#2650a6><IMG height=1 
                src="images/blank.gif" width=1 border=0><img src="images/Arrow1.gif" width="23" height="23"></TD>
              <TD width=165 height="29" bgColor=#7691c7>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A 
                class=nav 
                href="ExitServlet">退出</A></TD>
            </TR>
            <TR>
              <TD bgColor=#ffffff colSpan=2><IMG height=1 
                src="images/blank.gif" width=1 border=0></TD></TR>        <TR align=middle>
              <TD colSpan=2 height=160>&nbsp;</TD></TR>
            <TR>
              <TD colSpan=2><IMG height=1 src="images/blank.gif" 
            width=1></TD></TR></TBODY></TABLE></TD>
        <TD width=2 rowSpan=3><IMG height=1 src="images\blank(1).gif" width=2></TD>
        <TD width="2">
          <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
            <TBODY>
            <TR>
              <TD height=25>&nbsp;现在的位置:修改操作员>第二步</TD>
            </TR>
            <TR>
              <TD bgColor=#2650a6><IMG height=1 src="images\blank(1).gif" 
                width=1></TD></TR>
            <TR>
              <TD><IMG height=2 src="images\blank(1).gif" width=574></TD></TR></TBODY></TABLE></TD></TR>
      <TR vAlign=top>
        <TD height="600" bgColor=#f1f3f9>
        <form action="updataOperator" method="post">
        <table><tr>
        <%Operator oper=new Operator(); 
         oper=(Operator)session.getAttribute("oper");
        %>
          <td>登录ID:</td><td><input type="text" name="ID" size="20" value="<%=oper.getOperator_ID() %>"  readonly="readonly"></td>
          </tr>
          <tr>
          <td>姓 名:</td><td><input type="text" name="NAME" size="20" value="<%=oper.getOperator_Name() %>" ></td>
          </tr>
          <tr>
          <td>密 码:</td><td><input type="text" name="PWD" size="20" value="<%=oper.getOperatot_Pwd() %>"></td>
          </tr>
          <tr>
          <td>密码确认:</td><td><input type="text" name="TMPPWD" size="20" value="<%=oper.getOperatot_Pwd() %>"></td>
          </tr>
          </table><%
          String Y=null,N=null;
          if(oper.getIs_Admin().equals("y")){ Y ="checked"; N="";}
          else{ Y =""; N="checked";}
           %>
          <p>是否管理员:<input type="radio" value="y" <%=Y %> name="R1">是&nbsp;&nbsp;&nbsp; 
          <input type="radio" name="R1" value="n" <%=N %>>否</p>
          <p><input type="submit" value="修改" name="B1">
          <input type="submit" value="删除" name="B1"></p>
          </form>
        </TD>
        </TR>
      </TBODY></TABLE>
    <BR>
    </CENTER></BODY></HTML>
      

  7.   

    response.setContentType("GB2312");%> 这个是什么东西哦??你写错了!response.setCharactorEncoding("GB2312");
      

  8.   

    楼上的 有理,这是个问题 
    response.setContentType("");
    里面是输出文件的格式