| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 454 人关注过本帖
标题:信息提交出现错误(代码有误)
只看楼主 加入收藏
mzw1025
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-7-2
收藏
 问题点数:0 回复次数:3 
信息提交出现错误(代码有误)

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.io.*"%>
<%@ page import="java.net.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.*"%>
<%!
public String getStr(String str)
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("ISO8859_1");
String temp=new String(temp_t);
return temp;
}
catch(Exception e)
{}
return "null";
}
%>
<%
if(request.getParameter("submit")!=null){
String user=null;
String email=null;
String msg=null;
user=request.getParameter("user");
email=request.getParameter("email");
msg=request.getParameter("msg");
user=getStr(user.trim());
email=getStr(email.trim());
msg=getStr(msg.trim());
String ip=request.getRemoteAddr();
String flag="1";
Date cuurTime=new Date();
SimpleDateFormat formatter=new SimpleFormar("yyyy/MM/dd a hh:mm:ss",Locale.US);
String adate=formatter.format(currTime);
if((user.length()>0) && (msg.length()>0) && (email.length()>0)
{
String url=new String();
url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=liuyanben";
try
{
Class.forNmae("com.microsoft.jdbc.sqlserver.SQLServetDriver");
}
catch(java.lang.ClassNotFoundException ae)
{
System.out.print("error:"+ae.getMessage());
}
Connection con=DriverManager.getConnection(url,"sa","");
PreparedStatement prestmt=null;
String strSQL;
try
{
strSQL="insert into guestbook (Username,IP,Email,Comment,Mydate,Flag) values(?,?,?,?,?,?)";
prestmt=con.PreparedStatement(strSQL);
prestmt.setBytes(1,user.getBytes("GBK"));
prestmt.setBytes(2,ip.getBytes());
prestmt.setBytes(1,email.getBytes("GBK"));
prestmt.setBytes(1,msg.getBytes("GBK"));
prestmt.setBytes(1,adate.getBytes("GBK"));
prestmt.setBytes(1,flag.getBytes("GBK"));
prestmt.executeUpdate();
}
catch(Exception be)
{
System.out.print("be.executeQuery:"+be.getMessage());
}
con.close();
response.sendRedirect("http://172.17.9.129:8080/guestbook/index.jsp");
}
else
{
out.print("不能输入空白项!");
return;
}
}
else
{
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>填写留言</title>
</head>
<body bgcolor="ffffff">
<form method="post" action="http://172.17.9.129:8080/guestbook/addmsg.jsp">
<table border="0" cellpadding="2" width=400 align="center">
<tr>
<td nowrap width="20%"><font color="#FF6600">姓名:</font></td>
<td width="14%">
<input type="text" name=user size="8" class="form">
</td>
<td nowrap width="18%"><font color="#FF6600">电子邮件</font></td>
<td width="48%">
<input type="text" name="email" size="18" class="form">
</td>
</tr>
<tr>
<td nowrapvalign=top bordercolor="ffffff" width="20%"><font color="ffffff">留言内容</font></td>
<td colspan="3"><textarea rows=5 name="msg" cols="38" class="form"></textarea></td>
</tr>
<tr>
<td colspan="4" align="center">
<input type="submit" name="submit" value="提交留言" class="form">
<input type="reset" name="reset" value="重新填写" class="form">
</td>
</tr>
</table>
<div align="center"></div>
</form>
</body>
</html>
<%
}
%>





--------------------------------------------------------------------------------------------------------


HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 22 in the jsp file: /addmsg.jsp
Generated servlet error:
D:\Tomcat 5.0\work\Catalina\localhost\guestbook\org\apache\jsp\addmsg_jsp.java:88: ')' expected
{
^


An error occurred at line: 22 in the jsp file: /addmsg.jsp
Generated servlet error:
D:\Tomcat 5.0\work\Catalina\localhost\guestbook\org\apache\jsp\addmsg_jsp.java:126: illegal start of expression
}
^
2 errors

org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
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.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.28

搜索更多相关主题的帖子: 有误 代码 
2007-10-10 12:36
qdwwzzh
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-10-10
收藏
得分:0 

学习学习

2007-10-10 13:31
daone
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-5-11
收藏
得分:0 
2007-10-10 13:54
天使漫步云端
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-10-10
收藏
得分:0 
2007-10-10 13:56
快速回复:信息提交出现错误(代码有误)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050465 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved