what is the need foe giving *.do in the url pattern of web.xml
It's a way of telling the Application Server to call the Struts action servlet. If you specified "*.*" as the url pattern, everything, including image files, css files, etc. would cause the action servlet to be called, and this is not what you want.
do we have to write the action servlet or is it implemented by the container.
It is not implemented by the container, but it is provided by the authors of the Struts framework, and it resides in the struts.jar file that is in your classpath. You definitely don't have to write it and probably don't have to extend it unless you're doing something very unusual.