0

Hi im trying to do a simple servlet application im using (Eclipse IDE for Enterprise Java and Web Developers)

this is just a simple web application, because i want to see how the html and servlet works

this is the file structure

enter image description here

this is the html file

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form method="get" action="hi">

<pre>
Enter your name:
<input type="text" name=t1>
<input type="submit">



</pre>

</form>
</body>
</html>

this is the servlet page



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;

/**
 * Servlet implementation class HelloSrvlet
 */
@WebServlet("/hi")
public class HelloServlet 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 {
    
        PrintWriter pw = response.getWriter();
        String s = request.getParameter("t1");
        pw.println(s);
        pw.close();
    }


}

so when i run the html file. Input data and submit the html form

it shows this on the web page

HTTP Status 404 – Not Found

Type Status Report

Message The requested resource [/DemoServlet/hi] is not available
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/9.0.53

this is quite a simple application... but i got no idea why it is not working

BalusC
  • 1,040,783
  • 362
  • 3,548
  • 3,513
Nuvo
  • 1
  • 2

0 Answers0