java - Servlet: HTTP Status 404 - /Test/SimpleServletPath -


i have created small dynamic web project understand mechanism of java servlet when run simpleservlet on server getting http status 404 error when typing url http://localhost:8082/test/ getting content of index.html file rendered. dont have web.xml file. how can run servlet on server?

simpleservlet

package org.user;  import java.io.ioexception; import java.io.printwriter;  import javax.servlet.servletcontext; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import javax.servlet.http.httpsession;  @webservlet(description = "a simple servlet", urlpatterns = { "/simpleservletpath" }) public class simpleservlet extends httpservlet {     private static final long serialversionuid = 1l;      /**      * @see httpservlet#doget(httpservletrequest request, httpservletresponse      *      response)      */     protected void doget(httpservletrequest request,             httpservletresponse response) throws servletexception, ioexception {         response.setcontenttype("text/html");         printwriter writer = response.getwriter();         string username = request.getparameter("username");         httpsession session = request.getsession();         // use username in different browser.         servletcontext context = request.getservletcontext();          if (username != null && !username.isempty()) {              session.setattribute("savednameuser", username);             context.setattribute("savednameuser", username);          }          writer.println("request parameter has username  " + username                 + "</br>");          writer.println("session parameter has username  "                 + (string) session.getattribute("savednameuser") + "</br>");          writer.println("context parameter has username  "                 + (string) context.getattribute("savednameuser"));      } } 

image

enter image description here

this not solution worked me. had change eclipse workspace directory , built project again. tried in new project same servlet , worked me.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -