I would like to be able to receive a request on a servlet I made, then analyse the URL and configure the application database based on that, and after the DB is configure forward the request to the regular Faces Servlet.
How should I configure my web.xml? And how can I forward the request to the Faces Servlet?
Here is what I was thinking:
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>aws</servlet-name>
<servlet-class>servlets.aws</servlet-class>
</servlet>
<!-- <servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>-->
<servlet-mapping>
<servlet-name>aws</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
System.out.println("configure DB based on URL");
RequestDispatcher rd = request.getRequestDispatcher("FacesServlet");
rd.forward(request, response);
}
However that gives the following error: