Good evening, I installed a java/tomcat webapp using servlets and jsp on an online domain. The main page is displayed, but when I go to user registration and send the data, then the first servlet starts working, the page remains blank and the url becomes domainname/ServletName. I cannot view the logs because it is a shared host and I have no idea how to fix. Thoughts or help?
This is the servlet's code
package controller;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
/**
* Servlet implementation class RegisterAdmin
*/
public class RegisterAdmin extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public RegisterAdmin() {
super();
// TODO Auto-generated constructor stub
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String name = request.getParameter("name");
String cognome = request.getParameter("cognome");
String user = request.getParameter("user");
String pass = request.getParameter("password");
String query = "INSERT INTO admin (nome, cognome, username, password) VALUES (?, ?, ?, ?)";
try {
Connection conn = null;
try {
conn = DBConnector.connect();
} catch (Exception e) {
e.printStackTrace();
}
PreparedStatement preparedStatement = conn.prepareStatement(query);
preparedStatement.setString(1, name);
preparedStatement.setString(2, cognome);
preparedStatement.setString(3, user);
preparedStatement.setString(4, pass);
preparedStatement.executeUpdate();
response.setContentType("text/html");
RequestDispatcher view = request.getRequestDispatcher("index.jsp");
view.include(request, response);
try {
if (conn != null) conn.close();
}catch (SQLException e) {
e.printStackTrace();
}
}catch(Exception e) {
e.printStackTrace();
}
}
}