0

In a Dynamic Web Project, I am trying to run a servlet from a html file. The html file loads fine but when the form is triggered, it shows a 404 error.

login.html

<form class="form-signin" method="POST" action="/ECommerce/Auth">
      <a href="index.html"><img class="mb-4" src="img/Store.XYZ.png" alt="" height="30" width="180"></a>
      <label for="inputEmail" class="sr-only">Email address</label>
      <input type="email" id="loginusername" class="form-control" placeholder="Email address" style="margin-bottom: 4px;"  required autofocus>
      <label for="inputPassword" class="sr-only">Password</label>
      <input type="password" id="loginpassword" class="form-control" placeholder="Password" style="margin-bottom: 4px;" required>
      <button class="btn btn-lg btn-primary btn-block" style="margin-top: 12px; margin-bottom: 5px;"  type="submit">Sign in</button>
      <a href="register.html"><button class="btn btn-sm btn-secondary btn-block" onclick="location.href='register.html'">Don't have an account? Register</button></a>
</form>

Auth.java


import java.io.IOException;
import java.io.PrintWriter;
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 java.sql.*;
import java.util.Scanner;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader;

@WebServlet("/Auth")
public class Auth extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public Auth() {
        Statement stmt = null;
        
        try {
            Connection con = DatabaseConnection.initializeDatabase();
            System.out.println("Connected database successfully...");
            
......

Project structure is as follows; Project Directory

Error Screen: enter image description here

Utkarsh Sharma
  • 61
  • 2
  • 12

1 Answers1

0

Changing Tomcat from v10 to v7 worked.

Utkarsh Sharma
  • 61
  • 2
  • 12