java - HTTP status 404 error from Tomcat -


i'm new servlet i'm testing first servlet program giving http status 404 error. things have done are:

1> installed java-> c:\program files\java\jdk1.6.0

2> installed tomcat-> c:\apache-tomcat-7.0

3> when type -> localhost:8080 in browser works fine.

4> directory folder created-> c:\apache-tomcat-7.0.23\webapps\examples.

it contains web.xml file , web-inf folder.

inside web-inf, there folder named classes, contains validate.class

the souce code java file 'validate.java' given below-

import javax.servlet.http.*; import javax.servlet.*; import java.io.*; import java.lang.*; public class validate extends httpservlet{ public void service(httpservletrequest req,httpservletresponse res) throws servletexception,ioexception{     string name=req.getparameter("tb");     string pass=req.getparameter("pass");     string name1=getinitparameter("usrnme1");     string pass1=getinitparameter("pswrd1");     cookie c1=new cookie(name1,pass1);     res.addcookie(c1);     string name2=getinitparameter("usrnme2");     string pass2=getinitparameter("pswrd2");     cookie c2=new cookie(name2,pass2);     res.addcookie(c2);     string name3=getinitparameter("usrnme3");     string pass3=getinitparameter("pswrd3");     cookie c3=new cookie(name3,pass3);     res.addcookie(c3);     string name4=getinitparameter("usrnme4");     string pass4=getinitparameter("pswrd4");     cookie c4=new cookie(name4,pass4);     res.addcookie(c4);     res.setcontenttype("text/html");     printwriter out=res.getwriter();     cookie[] c=req.getcookies();     if(c!=null)     {         for(int i=0;i<c.length;i++)         {             if(c[i].getname()==name && c[i].getvalue()==pass)             {                 out.println("<html><body><center>");                 out.println("hello"+"<b>c[i].getname()</b>");                 out.println("</center></body></html>");                 break;             }             else             {                 out.println("<html><body><center>");                 out.println("not valid user");                 out.println("</center></body></html>");                 break;             }         }     } } } 

web.xml file code-

<?xml version="1.0"?> <web-app> <servlet>     <servlet-name>validate</servlet-name>     <servlet-class>validate</servlet-class> </servlet> <init-param>     <param-name>usrnme1</param-name>     <param-value>user1</param-value> </init-param> <init-param>     <param-name>pswrd1</param-name>     <param-value>pwd1</param-value> </init-param> <init-param>     <param-name>usrnme2</param-name>     <param-value>user2</param-value> </init-param> <init-param>     <param-name>pswrd2</param-name>     <param-value>pwd2</param-value> </init-param> <init-param>     <param-name>usrnme3</param-name>     <param-value>user3</param-value> </init-param> <init-param>     <param-name>pswrd3</param-name>     <param-value>pwd3</param-value> </init-param> <init-param>     <param-name>usrnme4</param-name>     <param-value>user4</param-value> </init-param> <init-param>     <param-name>pswrd4</param-name>     <param-value>pwds4</param-value> </init-param> <servlet-mapping>     <servlet-name>validate></servlet-name>     <url-pattern>/validate</url-pattern> </servlet-mapping> </web-app> 

after reading few suggestions tried changing url /validate.htm (or .html) still same error message.


http status 404 - /examples/validate.html  type status report  message /examples/validate.html  description requested resource (/examples/validate.html) not available.  apache tomcat/7.0.27 ****************************************************** log file catalina.2015-04-22 is-   apr 22, 2015 9:08:18 pm org.apache.catalina.core.aprlifecyclelistener init  info: apr based apache tomcat native library allows optimal  performance in production environments not found on java.library.path:   c:\program files (x86)\apache software foundation\tomcat   7.0\bin;.;c:\windows\sun\java\bin;c:\windows\system32;c:\windows;c:\programdata\  oracle\java\javapath;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\  windows\system32\windowspowershell\v1.0\;c:\program files   (x86)\java\jdk1.8.0_31\bin;c:\program files   (x86)\java\jre1.8.0_31\bin;c:\turboc++\disk\turboc3\bin;c:\program files   (x86)\skype\phone\;c:\program files (x86)\java\jdk1.6.0_25\bin;c:\program files   (x86)\java\jre6\bin;c:\program files (x86)\apache software foundation\tomcat   7.0\lib;  apr 22, 2015 9:08:18 pm org.apache.coyote.abstractprotocol init  info: initializing protocolhandler ["http-bio-8080"]  apr 22, 2015 9:08:18 pm org.apache.coyote.abstractprotocol init  info: initializing protocolhandler ["ajp-bio-8009"]  apr 22, 2015 9:08:18 pm org.apache.catalina.startup.catalina load  info: initialization processed in 495 ms  apr 22, 2015 9:08:19 pm org.apache.catalina.core.standardservice startinternal  info: starting service catalina  apr 22, 2015 9:08:19 pm org.apache.catalina.core.standardengine startinternal  info: starting servlet engine: apache tomcat/7.0.27  apr 22, 2015 9:08:19 pm org.apache.catalina.startup.hostconfig deploydirectory  info: deploying web application directory c:\program files (x86)\apache software foundation\tomcat 7.0\webapps\docs  apr 22, 2015 9:08:19 pm org.apache.catalina.startup.hostconfig deploydirectory  info: deploying web application directory c:\program files (x86)\apache software foundation\tomcat 7.0\webapps\examples  apr 22, 2015 9:08:19 pm org.apache.catalina.startup.hostconfig deploydirectory  info: deploying web application directory c:\program files (x86)\apache software foundation\tomcat 7.0\webapps\host-manager  apr 22, 2015 9:08:19 pm org.apache.catalina.startup.hostconfig deploydirectory  info: deploying web application directory c:\program files (x86)\apache software foundation\tomcat 7.0\webapps\manager  apr 22, 2015 9:08:19 pm org.apache.catalina.startup.hostconfig deploydirectory  info: deploying web application directory c:\program files (x86)\apache software foundation\tomcat 7.0\webapps\root  apr 22, 2015 9:08:19 pm org.apache.coyote.abstractprotocol start  info: starting protocolhandler ["http-bio-8080"]  apr 22, 2015 9:08:19 pm org.apache.coyote.abstractprotocol start  info: starting protocolhandler ["ajp-bio-8009"]  apr 22, 2015 9:08:19 pm org.apache.catalina.startup.catalina start  info: server startup in 785 ms  apr 22, 2015 9:12:20 pm org.apache.catalina.startup.hostconfig checkresources  info: reloading context [/examples]  apr 22, 2015 9:12:24 pm org.apache.catalina.startup.hostconfig checkresources  warning: error during context [/examples] restart  org.apache.catalina.lifecycleexception: failed start component   [standardengine[catalina].standardhost[localhost].standardcontext[/examples]]      @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:154)      @   org.apache.catalina.startup.hostconfig.checkresources(hostconfig.java:1366)      @ org.apache.catalina.startup.hostconfig.check(hostconfig.java:1454)      @   org.apache.catalina.startup.hostconfig.lifecycleevent(hostconfig.java:295)      @   org.apache.catalina.util.lifecyclesupport.firelifecycleevent(lifecyclesupport.java:119)      @   org.apache.catalina.util.lifecyclebase.firelifecycleevent(lifecyclebase.java:90)      @   org.apache.catalina.core.containerbase.backgroundprocess(containerbase.java:1379)      @   org.apache.catalina.core.containerbase$containerbackgroundprocessor.processchild  ren(containerbase.java:1537)      @   org.apache.catalina.core.containerbase$containerbackgroundprocessor.processchild  ren(containerbase.java:1547)      @   org.apache.catalina.core.containerbase$containerbackgroundprocessor.run(containe  rbase.java:1526)      @ java.lang.thread.run(unknown source)  caused by: java.lang.illegalargumentexception: servlet mapping specifies   unknown servlet name hai>      @   org.apache.catalina.core.standardcontext.addservletmapping(standardcontext.java:  3204)      @   org.apache.catalina.core.standardcontext.addservletmapping(standardcontext.java:  3183)      @ org.apache.catalina.deploy.webxml.configurecontext(webxml.java:1302)      @   org.apache.catalina.startup.contextconfig.webconfig(contextconfig.java:1294)      @   org.apache.catalina.startup.contextconfig.configurestart(contextconfig.java:855)      @   org.apache.catalina.startup.contextconfig.lifecycleevent(contextconfig.java:345)      @   org.apache.catalina.util.lifecyclesupport.firelifecycleevent(lifecyclesupport.ja  va:119)      @   org.apache.catalina.util.lifecyclebase.firelifecycleevent(lifecyclebase.java:90)      @   org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5161  )      @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150)      ... 10 more  apr 22, 2015 9:37:00 pm org.apache.catalina.startup.hostconfig checkresources  info: reloading context [/examples] apr 22, 2015 9:37:04 pm org.apache.catalina.startup.hostconfig checkresources  warning: error during context [/examples] restart org.apache.catalina.lifecycleexception: failed start component [standardengine[catalina].standardhost[localhost].standardcontext[/examples]]     @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:154)     @ org.apache.catalina.startup.hostconfig.checkresources(hostconfig.java:1366)     @ org.apache.catalina.startup.hostconfig.check(hostconfig.java:1454)     @ org.apache.catalina.startup.hostconfig.lifecycleevent(hostconfig.java:295)     @ org.apache.catalina.util.lifecyclesupport.firelifecycleevent(lifecyclesupport.java:119)     @ org.apache.catalina.util.lifecyclebase.firelifecycleevent(lifecyclebase.java:90)     @ org.apache.catalina.core.containerbase.backgroundprocess(containerbase.java:1379)     @ org.apache.catalina.core.containerbase$containerbackgroundprocessor.processchildren(containerbase.java:1537)     @ org.apache.catalina.core.containerbase$containerbackgroundprocessor.processchildren(containerbase.java:1547)     @ org.apache.catalina.core.containerbase$containerbackgroundprocessor.run(containerbase.java:1526)     @ java.lang.thread.run(unknown source) caused by: java.lang.illegalargumentexception: servlet mapping specifies unknown servlet name validate>     @ org.apache.catalina.core.standardcontext.addservletmapping(standardcontext.java:3204)     @     org.apache.catalina.core.standardcontext.addservletmapping(standardcontext.java:    3183)     @ org.apache.catalina.deploy.webxml.configurecontext(webxml.java:1302)     @     org.apache.catalina.startup.contextconfig.webconfig(contextconfig.java:1294)     @     org.apache.catalina.startup.contextconfig.configurestart(contextconfig.java:855)     @     org.apache.catalina.startup.contextconfig.lifecycleevent(contextconfig.java:345)      @     org.apache.catalina.util.lifecyclesupport.firelifecycleevent(lifecyclesupport.java:119)      @     org.apache.catalina.util.lifecyclebase.firelifecycleevent(lifecyclebase.java:90)      @    org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5161)      @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150)     ... 10 more 

please me out possible. i'll thankful you.


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

c++ - No viable overloaded operator for references a map -

java - UML - How would you draw a try catch in a sequence diagram? -