I'm trying to create a web application. While inserting into token table for login, it throws an exception and I can't figure out the reason it prints "catch Invalid"
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
request.setCharacterEncoding("UTF-8");
String email=request.getParameter("email");
String password=request.getParameter("password");
byte[]passwordBytes=password.getBytes();
PrintWriter writer=response.getWriter();
try {
MessageDigest messageDigest=MessageDigest.getInstance("MD5");
byte[]hashBytes=messageDigest.digest(passwordBytes);
String hash=new String (hashBytes);
DatabaseHelper helper=new DatabaseHelper();
String token=helper.signin(email,hash);
if(token!=null){
writer.print(token);
}
else{
writer.print("Invalid");
}
} catch (Exception e) {
writer.print("catch invalid");
}
}