• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

help me!

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<%@ 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
 
pei zhaohui
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry,my english is so bad!
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the second line ,
replace <%@ import="java.sql.*;"%> with <%@page import="java.sql.*;"%>

The import should be the part of page directive.
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"BBBBBB GGGGG",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
He got surgery to replace his foot with a pig. He said it was because of this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic