1

If I am not including web.xml file then index file is opening properly but result page HelloWorld.jsp is giving 404 error, and when including web.xml index page is giving 404 error.

I have index.jsp file. localhost:8080 is working correctly but after that it is giving error.

See here:


enter image description here

Roman C
  • 49,761
  • 33
  • 66
  • 176
  • Possible duplicate of [Exception starting filter struts2 - tried adding JAR's, but same result](http://stackoverflow.com/questions/17096637/exception-starting-filter-struts2-tried-adding-jars-but-same-result) – Andrea Ligios Mar 15 '16 at 08:49

1 Answers1

0

In the first case the index file is opened by the default servlet, that is available on the server.

In the second case you use FilterDispatcher that is deprecated.

You should upgrade Struts to the latest version and use

<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 

See how to write web application descriptor web.xml.

Simple Example

Configuring web.xml for the framework is a matter of adding a filter and filter-mapping.

FilterDispatcher Example (web.xml):

<web-app id="WebApp_9" version="2.4"
    xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!-- ... -->

</web-app>
Roman C
  • 49,761
  • 33
  • 66
  • 176