I have a Servlet class I made to handle functions I don't want to repeat on every Servlet I have. I'm still working on it (i.e. it still only loads index.jsp and not other files).
public class MyServlet extends HttpServlet {
public MyServlet () {
super();
}
public void loadView (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
RequestDispatcher dispatcher = request.getRequestDispatcher("/index.jsp");
response.setContentType("text/html;charset=UTF-8");
System.out.println("MyServlet::LoadView() success");
dispatcher.forward(request, response);
}
}
My Servlet is as follows
@WebServlet(name = "EditServlet", urlPatterns = {"/content/edit"})
public class EditServlet extends Library.MyServlet {
public EditServlet () {
super();
}
public void doGet (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("EditServlet loaded");
}
}
I am however, unable to compile my code:
SEVERE: Exception while deploying the app [ContentManagement] : (class: contentmanagement/content/EditServlet, method: <init> signature: ()V) Constructor must call super() or this()
update
Ok, removing void
on my constructors and calling super();
got the must call first
portion to go away, but it's still saying I have to call super despite that it's already being called.
update
I don't understand the responses below.... they keep saying to put super()
within the constructor, when my examples already show that being done, AND it is the first line of code. Any other advice would be appreciated.
Any thoughts?
This is now a non-issue. I do not know what resolved this issue, but with multiple changes and rebuilding my app from the ground up I am no longer experiencing this issue