Recently, I have been learning jsp and servlets, and I can’t avoid dealing with tomcat, but Tomcat often has various errors. Below are some common solutions I have summarized, I hope they will be useful to everyone.
1. Web application not deployed
2. URL entry error
Troubleshooting method: First, check whether the URL's IP address and port number are written correctly.
Secondly, check whether the context path is correct. Project-------Properties----MyElipse----Web----Web Context-root checks whether the path name is written correctly.
Finally, check whether the file name is written correctly.
3. Directory cannot be referenced
Troubleshooting method:
Check the location of files stored in Eclipse's "Package Explorer". Since the contents under the META-INFWEB-INF folder cannot be published to the public, if you reference a file with these two directories, it is definitely not allowed. For example: http://localhost:8080/guestbook/WEB-INF/
It's the wrong file location storage error
4. Problems in Tomcat server
How to troubleshoot:
If your web application has multiple jsp pages, you may get a 404 error when you click on the virtual root directory of your web application, but you only need to modify the Tomcat server.
<init-param> <param-name>listings</param-name> <param-value>false(Put it astrue)</param-value> </init-param>
5. There must be several fixed folders and files under WEB-INF.
±
The configuration file of the web app
±lib
The library files used in this web app
±classes
°Storing compiled servlet
Please pay attention to their names. I used to write classes as class. I checked the error for half a night but it has not been solved. So you must be careful when writing these, so if you want to waste more?energy to check the wrong.
6. If you want to run not a .jsp file, but a servlet (.class) file, you need to configure (of course, below WEB-INF), add the following fields:
<servlet> <servlet-name>HelloWorldServlet</servlet-name> <servlet-class>HelloWorldServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>HelloWorldServlet</servlet-name> <url-pattern>/HelloWorldServlet</url-pattern> </servlet-mapping>
Change the "HelloWorldServlet" to the file name you want to run. I have roughly summarized these. Of course, there may be more unexpected errors in actual applications, which is normal. If there are any errors, please point them out.
This is the article about the solution to HTTP Status 404 errors in Javaweb project operation. For more information about HTTP Status 404, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!