I am getting 404 error while trying to deploy a servlet project. I took the war file from Netbeans and copied it in the webapps folder inside the tomcat folder.
Code :
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<servlet>
<servlet-name>UploadServlet</servlet-name>
<servlet-class>com.example.Upload</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UploadServlet</servlet-name>
<url-pattern>/UploadFile/UploadServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
index.html :
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>File Uploading Form</title>
</head>
<body>
<h3>File Upload:</h3>
Select a file to upload: <br />
<form action="UploadServlet" method="post"
enctype="multipart/form-data">
<input type="file" name="file" />
<br />
<input type="submit" value="Upload File" />
</form>
</body>
</html>
If I comment the servlet mapping and servlet part in web.xml, I can see the index.html. After undoing, I see just 404 error page. Please let me know what could be the error? Also what Actually I am suppose to write in action part and url-pattern in the web.xml
Thanks in advance.
localhost:8080/UploadFile/UploadServlet
try this – sadhu