5 Replies Latest reply on Mar 10, 2019 8:18 AM by jaikiran

    Wildfly-13/15, display error page when JSP page not found

    andrecouture

      Hi,

       

      I have this Servlet that have different actions defined.

      I'm trying to catch when a user enter a wrong JSP page and redirect to an error page (403 for example).

       

      For some reasons it works for some path but not all???

       

      for example

      Matched default handler path /portal/badpage.jsp

      Attempting to authenticate /portal/badpage.jsp, authentication required: false

      Authentication outcome was NOT_ATTEMPTED with method io.undertow.security.impl.CachedAuthenticatedSessionMechanism@75e6f047 for /portal/badpage.jsp

      Authentication result was ATTEMPTED for /portal/badpage.jsp

      servletPath: /portal/badpage.jsp

       

      then I get a blank page with an empty <body></body>

       

      But if I do enter /speak/badpage.jsp

       

      Matched default handler path /speak/badpage.jsp

      Attempting to authenticate /speak/badpage.jsp, authentication required: false

      Authentication outcome was NOT_ATTEMPTED with method io.undertow.security.impl.CachedAuthenticatedSessionMechanism@75e6f047 for /speak/badpage.jsp

      Authentication result was ATTEMPTED for /speak/badpage.jsp

      servletPath: /speak/badpage.jsp

       

      but the I do get redirected to my error page..

       

      I'm pretty sure it has to do with some differences in the web.xml but so far I could not figure out.

       

      Can someone help?

      PS: The system was configured long ago on Wildfly8 by another developer, I used the migration tool to upgrade from 8 to 11 then to 13 and now to 15.0.1..

        • 1. Re: Wildfly-13/15, display error page when JSP page not found
          jaikiran

          What does your web.xml file look like, for this application?

          • 2. Re: Wildfly-13/15, display error page when JSP page not found
            andrecouture

             

             

            Here it is, I h ave removed some sections that I are kinda repetitive...

             

            <?xml version="1.0" encoding="ISO-8859-1"?>

             

            <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"

                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee

                     http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"

                     version="3.1">

             

                    <distributable/>

                    <display-name>My Server</display-name>

             

                    <filter>

                            <filter-name>SecurityFilter</filter-name>

                            <filter-class>com.xxxxxx.server.web.filter.SecurityFilter</filter-class>

                    </filter>

             

                    <filter-mapping>

                            <filter-name>SecurityFilter</filter-name>

                            <servlet-name>action</servlet-name>

                    </filter-mapping>

             

                    <filter-mapping>

                            <filter-name>SecurityFilter</filter-name>

                            <url-pattern>*.jsp</url-pattern>

                    </filter-mapping>

             

                    <filter>

                            <filter-name>PortalFilter</filter-name>

                            <filter-class>com.xxxxxx.server.web.filter.PortalFilter</filter-class>

                    </filter>

             

                    <filter-mapping>

                            <filter-name>PortalFilter</filter-name>

                            <url-pattern>/portal/*</url-pattern>

                    </filter-mapping>

             

                    <filter>

                            <filter-name>WebPlayerFilter</filter-name>

                            <filter-class>com.xxxxxx.server.web.filter.WebPlayerFilter</filter-class>

                    </filter>

            ...

                    <filter>

                            <filter-name>PartnerFilter</filter-name>

                            <filter-class>com.xxxxxx.server.web.filter.PartnerFilter</filter-class>

                    </filter>

             

                    <filter-mapping>

                            <filter-name>PartnerFilter</filter-name>

                            <url-pattern>/admin/login/*</url-pattern>

                    </filter-mapping>

             

                    <filter-mapping>

                            <filter-name>PartnerFilter</filter-name>

                            <url-pattern>/admin/</url-pattern>

                    </filter-mapping>

             

                    <filter-mapping>

                            <filter-name>PartnerFilter</filter-name>

                            <url-pattern>/admin</url-pattern>

                    </filter-mapping>

             

                    <filter>

                            <filter-name>DBFilter</filter-name>

                            <filter-class>com.xxxxxx.server.common.struts.DBFilter</filter-class>

                    </filter>

             

                    <filter-mapping>

                            <filter-name>DBFilter</filter-name>

                            <url-pattern>*.jsp</url-pattern>

                            <dispatcher>FORWARD</dispatcher>

                            <dispatcher>REQUEST</dispatcher>

                    </filter-mapping>

             

                    <filter>

                            <filter-name>DBFilter2</filter-name>

                            <filter-class>com.xxxxxx.server.common.struts.DBFilter</filter-class>

                    </filter>

             

                    <filter-mapping>

                            <filter-name>DBFilter2</filter-name>

                            <url-pattern>/webservices/*</url-pattern>

                            <dispatcher>FORWARD</dispatcher>

                            <dispatcher>REQUEST</dispatcher>

                    </filter-mapping>

             

                    <listener>

                            <listener-class>com.xxxxxx.server.portal.SessionListener</listener-class>

                    </listener>

                    <servlet>

                            <servlet-name>apiTZ</servlet-name>

                            <servlet-class>com.xxxxxx.server.common.TimeZoneInitServlet</servlet-class>

                            <init-param>

                                    <param-name>timeZone</param-name>

                                    <param-value>GMT</param-value>

                            </init-param>

                            <load-on-startup>1</load-on-startup>

                    </servlet>

             

                    <servlet>

                            <servlet-name>serverstatus</servlet-name>

                            <servlet-class>com.xxxxxx.server.common.util.ServerStatusReporterServletWithJNDIConnection</servlet-class>

                            <load-on-startup>1</load-on-startup>

                    </servlet>

             

                    <servlet>

                            <servlet-name>action</servlet-name>

                            <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>

                            <init-param>

                                    <param-name>config</param-name>

                                    <param-value>/WEB-INF/struts-config-portal.xml,/WEB-INF/struts-config-api.xml,/WEB-INF/struts-config-admin.xml,/WEB-INF/struts-config-stat.xml,/WEB-INF/struts-config-esl.xml</param-value>

                            </init-param>

             

                            <init-param>

                                    <param-name>chainConfig</param-name>

                                    <param-value>org/apache/struts/tiles/chain-config.xml</param-value>

                            </init-param>

             

                            <load-on-startup>1</load-on-startup>

                    </servlet>

                    <servlet-mapping>

                            <servlet-name>serverstatus</servlet-name>

                            <url-pattern>/admin/status</url-pattern>

                    </servlet-mapping>

             

                    <servlet-mapping>

                            <servlet-name>action</servlet-name>

                            <url-pattern>*.do</url-pattern>

                    </servlet-mapping>

            ...

                    <!-- The Usual Welcome File List -->

                    <welcome-file-list>

                            <welcome-file>index.jsp</welcome-file>

                    </welcome-file-list>

             

                    <error-page>

                            <error-code>401</error-code>

                            <location>/admin/errors/error401.jsp</location>

                    </error-page>

             

                    <error-page>

                            <error-code>403</error-code>

                            <location>/admin/errors/error403.jsp</location>

                    </error-page>

             

                    <error-page>

                            <error-code>404</error-code>

                            <location>/admin/errors/error404.jsp</location>

                    </error-page>

             

                    <error-page>

                            <error-code>500</error-code>

                            <location>/admin/errors/error.jsp</location>

                    </error-page>

             

                    <mime-mapping>

                            <extension>xsd</extension>

                            <mime-type>text/xml</mime-type>

                    </mime-mapping>

             

                    <session-config>

                            <session-timeout>10</session-timeout>

                            <cookie-config>

                                    <!--<path>/</path>-->

                                    <http-only>true</http-only>

                                    <secure>true</secure>

                            </cookie-config>

                            <tracking-mode>COOKIE</tracking-mode>

                    </session-config>

            ...

                    <jsp-config>

                            <taglib>

                                    <taglib-uri>http://jsptags.com/tags/navigation/pager</taglib-uri>

                                    <taglib-location>/WEB-INF/pager-taglib.tld</taglib-location>

                            </taglib>

                    </jsp-config>

            </web-app>

            • 3. Re: Wildfly-13/15, display error page when JSP page not found
              jaikiran

              Based on that web.xml :

               

              <error-page>

                              <error-code>401</error-code>

                              <location>/admin/errors/error401.jsp</location>

                      </error-page>

               

                      <error-page>

                              <error-code>403</error-code>

                              <location>/admin/errors/error403.jsp</location>

                      </error-page>

               

                      <error-page>

                              <error-code>404</error-code>

                              <location>/admin/errors/error404.jsp</location>

                      </error-page>

               

                      <error-page>

                              <error-code>500</error-code>

                              <location>/admin/errors/error.jsp</location>

                      </error-page>

              If any of the above error codes are thrown by the web server, then the application will be redirected to the specified locations. What HTTP status code is being returned in the case where you aren't seeing these error pages?

              • 4. Re: Wildfly-13/15, display error page when JSP page not found
                andrecouture

                Hi

                 

                Actually I get a blank page with no errors and no body.

                 

                URL example

                https://xxx.com/admin/css/badpage.jsp

                There are no jsp pages at that location

                 

                 

                /André

                • 5. Re: Wildfly-13/15, display error page when JSP page not found
                  jaikiran

                  In your web.xml there are certain filters that are applied for *.jsp. You will have to check which of those filters (if any) might be returning this 200 status code.