I have a servlet as jsp which is declared in xml, I want to migrate on Java Config. web-xml:
<servlet>
<servlet-name>App</servlet-name>
<jsp-file>/app/App.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>App</servlet-name>
<url-pattern>/app/App.html</url-pattern>
</servlet-mapping>
Java Config:
@Override
public void onStartup(ServletContext servletContext){
...
servletContext.addServlet("App", new AppServlet()).addMapping("/app/App.html");
}
private class AppServlet extends HttpServlet{
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp){
req.getRequestDispatcher("/app/App.jsp").forward(req,resp);
}
}
But, it's not working.
You may also try this with
@Webservlet
annotation -