Hi, guys, I'm new to the Servlets and I'm trying to implement some simple ones, but I'm having a problem, I'm telling you.
I am using the Intellij editor for the implementation of it. I have everything implemented: the class index.jsp and a class .java with the DoGet method that I would have to execute a super simple html code but it does not work, I send you the code that I have and the error it gives me (Everything compiles without problem )
index.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Registro</title>
</head>
<header class="jumbotron">
<h1>Prueba Servlet</h1>
</header>
<body>
<form action="Servlet" method="post">
<label>Nombre</label>
<input type="text" name="nombre"
placeholder="Introduce tu nombre">
<button type="submit">Enviar</button>
</form>
</body>
</html>
Servlet.java
public class Servlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try{
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servidor</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hola amigo: "+request.getParameter("nombre")+"</h1>");
out.println("</body>");
out.println("</html>");
}finally {
out.close();
}
}
}
The idea is that when I hit the send button, I say HELLO and the name I have given but I get the following error.
And this comes out in Intellij as you see this is all right so I do not know what is failing me: ((
Does anyone know why it fails? Thank you very much