简体   繁体   中英

HTTP Status 404 – Not Found after installing maven in Eclipse

I Am following a Tutorial on you tube and i come across an error which i have no clue about. i am not able to proceed what ever is in the tutorial unless i resolve this issue.

Created simple servlet with

protected void service(HttpServletRequest request, HttpServletResponse 
response) throws ServletException, IOException {

    System.out.println("COntrol is here with me");
    PrintWriter out =response.getWriter();
    out.println("Helloo dunya");

when i run this code it doesn't find the class and give 404 not found how ever if i call same servlett from jspFile . The jsp works fine but after clicking on Login Button which action is also on Login . it give the same error.

In short Tomcat is not able to fine Servlet

Package name: Com.Example.Login Servletname: Login

Web.xml : have this code

<servlet>
<description></description>
<display-name>Login</display-name>
<servlet-name>Login</servlet-name>
<servlet-class>Com.Example.Login</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/Login</url-pattern>
</servlet-mapping>
 </web-app>

the error is 404 not found with the exception

SEVERE: Allocate exception for servlet [Login]
java.lang.ClassNotFoundException: Com.Example.Login

and so on

please try to help me out.

According to the information that you have provided here, I guess its the problem with your package name and the class name,

first check whether your package name is correct? whether its

Com.Example.Login

or

com.example.login

And if its correct as you have mentioned here,

then check your <servlet-class>Com.Example.Login</servlet-class> in web.xml file this tag should refer to the exact class (the servlet)

So as you have mentioned here your package is

Com.Example.Login

and your class is

Login

your configuration should change as, <servlet-class>Com.Example.Login.Login</servlet-class> (referring to the exact servlet class) This should fix your error and please be informed that there are standards for package naming and there are really good reasons to them as well. Please refer them to increase your code quality. link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM