javax.servlet.ServletException: Class testservlet is not a Servlet
java.lang.ClassCastException: testservlet
Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
Originally posted by chelakkad ben:
Hello Dittmer,
In that case why is www.knobe.org:8080/servlets-examples working?
My app name is testservlet. This folder is in webapps. So the mapping in web.xml should be...
<web-app>
<servlet>
<servlet-name>testservlet</servlet-name>
<servlet-class>testservlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testservlet</servlet-name>
<url-pattern>/testservlet/testservlet</url-pattern>
</servlet-mapping>
</web-app>
Is that correct? The second 'testservlet' in the url-pattern being the class file. And the index.html in webapps/testservlet/ should have
<a href="testservlet/testservlet">Execute</a> . Right?
rgds
And the index.html in webapps/testservlet/ should have
<a href="testservlet/testservlet">Execute</a> . Right?
Originally posted by Ulf Dittmer:
This looks wrong. If index.html is in webapps/testservlet, then a URL of "testservlet/testservlet" would access "testservlet/testservlet/testservlet". Try either href="testservlet" or href="/testservlet/testservlet".
Originally posted by yu wang:
java.lang.ClassCastException means that your class have some problem. The tomcat don't think it as a servlet. Maybe your class don't have the post method.
If it's true that we are here to help others, then what exactly are the others here for?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |