首先建立了一个DBconn.java连接数据库的类然后在Adminbean.java中引入这个类在这个包中定义了添加用户的方法 当用户注册完毕点击提交的时候 表单内容就传给了一个
RegisterServlet.java 在其中引入了Adminbean.java 下面是servlet的代码 不知道是不是有错public class RegisterServlet extends HttpServlet {
public String codeToString(String str)
{
String s=str;
try{
byte tempB[]=s.getBytes("ISO-8859-1");
s=new String(tempB);
return s;
}
catch(Exception e){
return s;
}
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String flag=request.getParameter("flag");
AdminBean ab=new AdminBean();
if(flag.equals("addUser")){
String username=codeToString(request.getParameter("username"));
String netname=codeToString(request.getParameter("netname"));
String email=codeToString(request.getParameter("email"));
String password=codeToString(request.getParameter("password"));
String passwordquestion=codeToString(request.getParameter("passwordquestion"));
String passwordanswer=codeToString(request.getParameter("passwordanswer"));
String rand1=codeToString(request.getParameter("checkword"));
String rand2=(String)request.getSession().getAttribute("rand");
if(ab.addUser(username, netname, email, password, passwordquestion, passwordanswer, rand1, rand2)){
request.getSession().setAttribute("userName", username);
request.getRequestDispatcher("registerover.jsp").forward(request,response);}
else{
request.getRequestDispatcher("registered.jsp").forward(request, response);
}
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doGet(request,response);
}}
http404错误 亟待请高手进 不知道是不是 servlet出问题
所以应该不是服务器端出错了,如果是服务器端出错应该是500 你可以看下是不是这些你要跳转的页面不存在,还是路径错了,还要看下web.xml里是否配置了servlet是否写对了呢