Servlet.service() for servlet [jsp] in context with path [/luntan] threw exception [java.lang.IllegalStateException: getOutputStream() has already been called for this response] with root cause
java.lang.IllegalStateException: getOutputStream() has already been called for this response
java.lang.IllegalStateException: getOutputStream() has already been called for this response
throws ServletException, IOException {
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
HttpSession session=request.getSession();
String username=request.getParameter("username");
String password=request.getParameter("password1");
String email=request.getParameter("email");
String sRand1=(String)session.getAttribute("Rand");
String sRand2=(String)request.getParameter("checkcode");
String role="0";
if(sRand1.equals(sRand2)){
String sql="INSERT INTO userinfo (UserName,UserPassword,Email,Role) VALUES"+"('"+username+"','"+password+"','"+email+"','"+role+"')";
UserCotrl username1=new UserCotrl();
int a= username1.addUser(sql);
//boolean isSu=username1.addIssuc(username);
if (a==1){
request.getRequestDispatcher("success.jsp").forward(request,response);
}else {
request.getRequestDispatcher("fail.jsp").forward(request,response);
}
}
else{
out.print("验证码输入错误");
}
} public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { this.doGet(request, response);}
}