Olá Pessoal, tenho que recorrer aos especialistas…
o tomcat está rodando um servlet bem simples, quando eu executo pelo “Run As” no eclipse ele funciona normalmente, só que quando fecho o eclipse, importo pro tomcat (fora do eclipse, formato WAR), e executo uma página html (que irá chamar o servlet), ele aparece o erro “HTTP Status 500”.
html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login e Senha</title>
</head>
<body>
<form action = "TrabComPost" method="post">
<h2>Escolha uma música: </h2>
<p>
<input type="checkbox" name="musica" value = "ROCK"/>ROCK<br />
<input type="checkbox" name="musica" value = "POP" /> POP<br />
<input type="checkbox" name="musica" value = "DANCE" /> DANCE<br />
<input type="checkbox" name="musica" value = "MPB" />MPB <br />
<input type="checkbox" name="musica" value = "SERTANEJO" />Sertanejo <br />
</p>
<input type="submit" name="btEnviar" value = "Enviar" /> <br />
</form>
</body>
</html>
servlet
package meupacote;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class TrabComPost extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
static final long serialVersionUID = 1L;
public void destroy() {
super.destroy();
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String[] e = request.getParameterValues("musica");
String html = "<html><head>" +
"<title> musicas sendo puxadas pelo getparameter</title>" +
"</head>" +
"<body>" +
"<h2> MUSICAS ESCOLHIDAS </h2>";
for(int i=0; i < e.length; i++){
html += "<strong>" + e[i] + "</strong> <br />" ;
}
html += "</body></html>";
response.setContentType("text/html");
PrintWriter writer = response.getWriter();
writer.print(html);
writer.close();
}
public void init() throws ServletException {
super.init();
}
}
web.xml
<?xml version="1.0" encoding="UTF-8" ?>
- <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>PrimeiroProjetoUsandoEclipse</display-name>
- <servlet>
<description />
<display-name>Meu primeiro Servlet</display-name>
<servlet-name>TrabComPost</servlet-name>
<servlet-class>meupacote.TrabComPost</servlet-class>
</servlet>
- <servlet-mapping>
<servlet-name>TrabComPost</servlet-name>
<url-pattern>/TrabComPost</url-pattern>
</servlet-mapping>
- <welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
POR QUE SERÁ QUE NÂO ESTÀ RODANDO???
AGUARDO VCS, OBRIGADO