'How to map the standard JSP Servlet URL patterns and a JSP page in Google Guice

I have translated nearly all of my traditional web.xml over to using Google Guice's to benefit from dependency injection.

Is there a way to configure the following in the Servlet Listener rather than web.xml?

The standard JSP processing declaration in web.xml ...

<servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>*.jsp</url-pattern>
    <url-pattern>*.jspf</url-pattern>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>

I tried JspServlet.class but it rendered the pages raw...

public class ServletListener extends GuiceServletContextListener {

    private Injector injector;

    @Override
    protected Injector getInjector() {
        // See https://github.com/google/guice/wiki/ServletModule
        return Guice.createInjector(new ServletModule(){
            
            @Override
            protected void configureServlets() {

                bind(JspServlet.class).in(Scopes.SINGLETON);   
                serve("*.jsp","*.jspf","*.html").with(JspServlet.class);
                ...

Also how to target a JSP page in the Servlet Listener?

    <servlet>
        <description>route all deeplink requests to the search.jsp page instead</description>
        <servlet-name>deeplink</servlet-name>
        <jsp-file>/search.jsp</jsp-file>
    </servlet>
    <servlet-mapping>
        <servlet-name>deeplink</servlet-name>
        <url-pattern>/search/*</url-pattern>
    </servlet-mapping>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source