Sunday, 15 January 2012

tomcat - hello world in servlet not working -



tomcat - hello world in servlet not working -

i ma trying hours run simple hello world programme in eclipse ,with servlet not working , looked few tutorials no luck ,if 1 please

my error , project explorer

my servlet class

/** * servlet implementation class helloworldservlet */ public class helloworldservlet extends httpservlet { private static final long serialversionuid = 1l; /** * @see httpservlet#httpservlet() */ public helloworldservlet() { super(); // todo auto-generated constructor stub } /** * @see httpservlet#doget(httpservletrequest request, httpservletresponse response) */ protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { printwriter out = response.getwriter(); out.println("hello world"); } /** * @see httpservlet#dopost(httpservletrequest request, httpservletresponse response) */ protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { // todo auto-generated method stub }

web.xml

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web- app_2_5.xsd" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="webapp_id" version="2.5"> <display-name>firstservlet</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <servlet> <description></description> <display-name>helloworldservlet</display-name> <servlet-name>helloworldservlet</servlet-name> <servlet-class>com.theopentutorials.servlets.helloworldservlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>helloworldservlet</servlet-name> <url-pattern>/helloworldservlet</url-pattern> </servlet-mapping> </web-app>

delete bin directory , re-compile project. check if newly generated classes placed in bin

tomcat servlets

No comments:

Post a Comment