<%@ page contentTpye="text/html;charset=gb2312"%>
<%@ import="java.sql.*;"%>
<%!
public
String codeString(String s)
{
String str1=s;
try{
byte b[]=str1.getBytes("ISO-8859-1");
str1=new String(b);
return str1;
}
catch(Exception e)
{
return str1;
}
}
%>
<html>
<head><title></title></head>
<body>
<cneter>
<%
Connection con;
Statement sql;
ResultSet rs;
%>
<%
//if(session.isNew())
//{
// response.sendRedirect("userLogin.jsp");
// }
// else
//{
String logname="",password="",repass="",realname="",email="",phone="",address="";
logname=request.getParameter("logname");
logname=codeString(logname);
password=request.getParameter("password");
password=codeString(password);
repass=request.getParameter("repass");
repass=codeString(repass);
realname=request.getParameter("realname");
realname=codeString(realname);
email=request.getParameter("email");
email=codeString(email);
phone=request.getParameter("phone");
phone=codeString(phone);
address=request.getParameter("address");
address=codeString(address);
// }
%>
<%
try{Class.forName("org.gjt.mm.Driver").newInstance();}
catch(ClassNotFoundException e){}
try{
int rowscount=0;
con=DriverManager.getconnection("jdbc:mysql://localhost:3306/shop","root","021714228");
sql=con.createStatement();
rs=sql.executeQuery("select * from user where logname='"+logname+"'");
while(rs.next())
{
rowscount++;
}
if(rowscount==0)
{
String condition="insert into user values('"+logname+"','"+password+"','"+realname+"','"+address+"','"+phone+"','"+email+"')";
rs=sql.executeQuery(condition);
out.print("注册成功!);
}
else {
out.print("你输入的用户名已经曾在,请重新输入!");
}
catch(SQLException e2){
out.print(e2);
out.print("注册失败!");
}
%>
</center>
</body>
</html>
error!!!
****************************************************************
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: /register.jsp(2,4) Invalid directive
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:90)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:506)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1539)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:220)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:203)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:495)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:476)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:464)
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.30 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.30