Bom dia pessoal,
Bem estou aprendendo Servlet e meu professor passou um exercício, masi não está funcionando.
Já quebrei a cabeça aki, masi não consegui resolver.
Alguém ajuda?
Ele é bem básico, segue abaixo o código:
<?xml version=“1.0” encoding=“ISO-8859-1” ?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>”>
<html xmlns=“<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>”>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=ISO-8859-1” />
<title>“Meu Primeiro Servlet”</title>
</head>
<body>
<form action=“Meu Primeiro Servlet”>
Nome: <input type = “text” name = “nome”/>
<input type= “submit” name = “Submit” value = “Enviar” />
</form>
</body>
</html>
package br.com.univercidade.exemplo1;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MeuPrimeiroServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet
{
public MeuPrimeiroServlet()
{
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String nome = request.getParameter("nome");
if (nome == null)
nome = "";
response.setContentType("text/html;charset=ISO-3859-1");
String html ="<html>" + "<head><title>Trabalhando com Servlet no Eclipse</title></head>"+
"</head>" +
"<body>" +
"Seu nome é: <strong>" + nome + "</strong>"+
"</body>" +
"</html>";
PrintWriter out = response.getWriter();
out.print(html);
}
}