query.jsp代码如下:
<%@page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,java.util.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>插入数据</title>
</head>
<body>
<%! String xuehao,name,sex,age,jiguan,department,url,sql; %>
<%! int i;%>
<%! Connection conn;//定义数据库连接对象 %>
<%! ResultSet rs;//定义结果集对象 %>
<%! Statement stmt;//定义SQL语句对象 %>
<%
xuehao=request.getParameter("xuehao").trim();
name=request.getParameter("name").trim();
name=new String(name.getBytes("ISO-8859-1"));//编码转换
sex=request.getParameter("sex").trim();
sex=new String(sex.getBytes("ISO-8859-1"));
age=request.getParameter("age").trim();
i=Integer.parseInt(age);
jiguan=request.getParameter("jiguan").trim();
jiguan=new String(jiguan.getBytes("ISO-8859-1"));
department=request.getParameter("department").trim();
department=new String(department.getBytes("ISO-8859-1"));
if(xuehao.length()!=3){//检查学号的位数
response.sendRedirect("err.jsp");
}
if(name.equals("")){//检查姓名是否为空
response.sendRedirect("err.jsp");
}
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
url="jdbc:odbc:sun";
conn=DriverManager.getConnection(url,"","");//建立与数据库的连接
stmt=conn.createStatement();
sql="select * from student where xuehao="+" ' "+xuehao+" ' ";
rs=stmt.executeQuery(sql);
if(rs.getRow()>0){
response.sendRedirect("err.jsp");
}
sql="insert into student(xuehao,name,sex,age,jiguan,dept)";
sql=sql+"values('"+xuehao+"','"+name+"','"+sex+"','"+i+"','"+jiguan+"','"+department+"')";
stmt.executeUpdate(sql);
out.println("<font size=3 color=blue>正在处理信息,请稍后......</font><meta http-equiv='refresh' content='2;url=list.jsp'>");
rs.close();
stmt.close();
conn.close();
}
catch(Exception e){
response.sendRedirect("err.jsp");
}
%>
</body>
</html>
8 个解决方案
#1
运行是500错误
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.IllegalStateException
org.apache.coyote.tomcat5.CoyoteResponseFacade.sendRedirect(CoyoteResponseFacade.java:352)
org.apache.jsp.admin.query_jsp._jspService(query_jsp.java:110)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.IllegalStateException
org.apache.coyote.tomcat5.CoyoteResponseFacade.sendRedirect(CoyoteResponseFacade.java:352)
org.apache.jsp.admin.query_jsp._jspService(query_jsp.java:110)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
#2
org.apache.jsp.admin.query_jsp._jspService(query_jsp.java:110)
Check Log
Check Log
#3
楼上的大侠 能说明白点吗~!~
我该怎么做呀
谢谢了
我该怎么做呀
谢谢了
#4
别用response啦,用<jsp:forward page="err.jsp"/>
#5
可能和
org.apache.coyote.tomcat5.CoyoteResponseFacade.sendRedirect
找到编译后的java文件,看(query_jsp.java:110)
应该就明白了
org.apache.coyote.tomcat5.CoyoteResponseFacade.sendRedirect
找到编译后的java文件,看(query_jsp.java:110)
应该就明白了
#6
还是弄不出来~!~
大家快来帮帮忙吧
大家快来帮帮忙吧
#7
你再检查一下你的代码有没有错!
我也没有看出什么名堂呢!只是还是用那个<jsp:forward page = "err.jsp" />
这样可能要好一点!
我也没有看出什么名堂呢!只是还是用那个<jsp:forward page = "err.jsp" />
这样可能要好一点!
#8
response.sendRedirect("err.jsp");
后面不能再有输出内容,所以在 response.sendRedirect("err.jsp");
后面要加上retrun;
后面不能再有输出内容,所以在 response.sendRedirect("err.jsp");
后面要加上retrun;
#1
运行是500错误
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.IllegalStateException
org.apache.coyote.tomcat5.CoyoteResponseFacade.sendRedirect(CoyoteResponseFacade.java:352)
org.apache.jsp.admin.query_jsp._jspService(query_jsp.java:110)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.IllegalStateException
org.apache.coyote.tomcat5.CoyoteResponseFacade.sendRedirect(CoyoteResponseFacade.java:352)
org.apache.jsp.admin.query_jsp._jspService(query_jsp.java:110)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
#2
org.apache.jsp.admin.query_jsp._jspService(query_jsp.java:110)
Check Log
Check Log
#3
楼上的大侠 能说明白点吗~!~
我该怎么做呀
谢谢了
我该怎么做呀
谢谢了
#4
别用response啦,用<jsp:forward page="err.jsp"/>
#5
可能和
org.apache.coyote.tomcat5.CoyoteResponseFacade.sendRedirect
找到编译后的java文件,看(query_jsp.java:110)
应该就明白了
org.apache.coyote.tomcat5.CoyoteResponseFacade.sendRedirect
找到编译后的java文件,看(query_jsp.java:110)
应该就明白了
#6
还是弄不出来~!~
大家快来帮帮忙吧
大家快来帮帮忙吧
#7
你再检查一下你的代码有没有错!
我也没有看出什么名堂呢!只是还是用那个<jsp:forward page = "err.jsp" />
这样可能要好一点!
我也没有看出什么名堂呢!只是还是用那个<jsp:forward page = "err.jsp" />
这样可能要好一点!
#8
response.sendRedirect("err.jsp");
后面不能再有输出内容,所以在 response.sendRedirect("err.jsp");
后面要加上retrun;
后面不能再有输出内容,所以在 response.sendRedirect("err.jsp");
后面要加上retrun;