in that myContext folder I've created WEB-INF folder in that classes and lib folders like this
C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.26\webapps\ROOT\myContext\WEB-INF\classes
C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.26\webapps\ROOT\myContext\WEB-INF\lib
Now in myContext I've created main.html page which calls to servlet TemplateServlet.class file which is stored in classes folder
@ Divya I dunno but what i have learned according to that when click on Submit button it will submit test then it will go to web.xml file and in that in servlet mapping means here
it will search url-pattern test and now here we have url pattern test and now will see servlet-name i.e template and this name will be mapped to servlet-name in <servlet> here in below code
and when it matched to servlet -name i.e template it will go for servlet class file name i.e TemplateServlet and will search this TemplateServlet.class file in WEB-INF /classes folder in classes folder I have TemplateServlet.class i.e compiled java file now it will run that thats what i have been told
Dunno whether I'm correct or not but please correct me if I'm wrong
OMG !! hey friends It wasn't a problem of my code. I've successfully run this program with same code as typed at the beginning and also got correct output.
You know the problem was in version of Tomcat. Actually I had run above program using jakarta-tomcat-5.5.9. I installed that and copied all files as I mentioned above and deleted all content of web.xml and copied this in that
Ganesh Pat wrote:Finally got the answer it wan't problem of tomcat version. It ran because of the <web-app xmlns="http://java.sun.com/j2ee/xml/ns" version="2.4">
this code. Thank you all for your valuable support.
If your web.xml is using (servlets) 2.4, then your web app is developing against J2EE 1.4.
If you use a newer version of Tomcat, ideally it should work because it's backward compatible.