-1

We use a web.xml in which are configured different languages and its url-pattern

<servlet-mapping>
        <servlet-name>forwarder</servlet-name>
        <url-pattern>/nl/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>forwarder</servlet-name>
        <url-pattern>/en/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>forwarder</servlet-name>
        <url-pattern>/fr/*</url-pattern>
    </servlet-mapping>

This works fine if clients go to www.example.com/en/somePage for example But when a client goes to www.example.com/en/, we see a 404 is generated and than still goes to FORWARDER.

is there a a way to learn this url to web.xml -file?

Thank you

Stefan

We tried to add in the web.xml the following extra patterns:

<servlet-name>forwarder</servlet-name>
    <url-pattern>/en/</url-pattern>
</servlet-mapping>

and

<servlet-name>forwarder</servlet-name>
    <url-pattern>en/</url-pattern>
</servlet-mapping>

and

<servlet-name>forwarder</servlet-name>
    <url-pattern>/en/</url-pattern>
</servlet-mapping>

This all keeped gerating a 404-error

When I tried

<servlet-name>forwarder</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

the programm did not want to start-up.

  • Please refer to this post https://stackoverflow.com/questions/15385596/how-are-servlet-url-mappings-in-web-xml-used You have not posted your servlet code. Your '/en/*' should match the '/en/' and it does. My guess would be your servlet is returning 404 not Tomcat. Please check this aspect once, if the servlet is trying to resolve the page and since there is no page to find, then the implementation of the servlet may return 404, that would be my guess without actually looking at the servlet implementation. – Ironluca Aug 28 '23 at 16:54

0 Answers0