0

web.xml:

<web-app>
    <display-name>LoginFormStruts1</display-name>
 
    <servlet>
        <servlet-name>myActionController</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
       
        <init-param>
            <param-name>config</param-name>
            <param-value>/WEB-INF/struts-config.xml</param-value>
        
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
 
    <servlet-mapping>
        <servlet-name>myActionController</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
 
    <welcome-file-list>
        <welcome-file>login.jsp</welcome-file>
    </welcome-file-list>
 
</web-app>

Additionally, what is this line doing?

org.apache.struts.action.ActionServlet

Someone please explain the concepts behind this two lines.

Roman C
  • 49,761
  • 33
  • 66
  • 176

3 Answers3

0

In regular expression terminology
. - a "dot" indicates any character
* - means "0 or more instances of the preceding regex token"

So, your url ends with .do, Then servlet container map that to desired servlet.

swaroop pallapothu
  • 588
  • 1
  • 6
  • 15
  • Thanks @swaroop pallapothu Can I conclude that *.do means that it will automatically look out for my action servlet (Controller) in the project ? Moreover what about this line in my code org.apache.struts.action.ActionServlet – rohit patil Feb 27 '18 at 06:57
0

In web.xml you configure servlets used by web app and there mappings.

Particularly you have configured the action servlet implemented by Struts. The servlet is mapped by extension *.do.

Roman C
  • 49,761
  • 33
  • 66
  • 176
0

The app you created will accept http requests from links which ends with .do else there will be an error for example you make a get request to http://localhost:8080/myapp/anything.do

Alix
  • 78
  • 8