Thursday, May 2, 2013

Can we change the url-pattern in web.xml ..?


we can change the url-pattern to whatever we wish to see in the browser. Generally we may observe in most of the tutorials/books the common url patterns ..  

where in the url pattern *.htm refers to any name with an extension .htm.

If you want to change it to some other extension like .do, .action ..etc you can do that.

Suppose if we have a requirement such that we don't need any extension at the end of my web application's url. Then you can simply use ' / ' or ' /* ' instead of  ' *. extension'.

How it will work:

When we run the applicationa and send a request to server like this 

http://ip address: port number/ Application Name/ requested resource

Then the server will check for the last part of the url , the request resource 
(/requested resource) and compares with the url pattern configured in web.xml . If it matches then request will be forwarded to the corresponding controller configuration by the DispatcherServlet.

1 comment: