Boa Tarde Estou com dois problemas!
bom o primeiro e que eu acho que estou fazendo errado . Ja foi mapeado o Servlet no web.xml porem ele Nao inicializa! Tem que fazer algum INI para chamar o Servlet ou somente o mapeamento funcionaria ?
JSP
[code]<%–
Document : index
Created on : 05/03/2008, 13:51:13
Author : patrick
–%>
<%@page contentType=“text/html” pageEncoding=“UTF-8”%>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
“http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8”>
<title>JSP- Servlet Page</title>
</head>
<body>
<table width=“793” border=“1” align=“center”>
<tr>
<td height=“123” colspan=“4”></td>
</tr>
<tr>
<td width=“200” height=“25”> </td>
<td width=“200” height=“25”> </td>
<td width=“200” height=“25”> </td>
<td width=“200” height=“25”> </td>
</tr>
<tr>
<td height=“118”> </td>
<td colspan=“3” rowspan=“5”> </td>
</tr>
<tr>
<td height=“25”> </td>
</tr>
<tr>
<td height=“25”> </td>
</tr>
<tr>
<td height=“25”> </td>
</tr>
<tr>
<td height=“233”> </td>
</tr>
</table>
</body>
</html>
[/code]
WEB.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>pkgServlet.LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/LoginServlet</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Servlet
[code]
package pkgServlet;
import java.io.;
import java.net.;
import javax.servlet.;
import javax.servlet.http.;
/**
*
-
@author patrick
*/
public class LoginServlet extends HttpServlet {protected void sendLoginForm( HttpServletResponse response ,
boolean ErrorMessage)
throws ServletException, IOException {
response.setContentType(“text/html;charset=UTF-8”);
PrintWriter out = response.getWriter();
try {out.println("<html>"); out.println("<head>"); out.println("<title>Servlet LoginServlet</title>"); out.println("</head>"); out.println("<body>"); if(ErrorMessage) out.println("Login Incorreto! Tente Novamente.<BR>"); out.println("<BR> Por Favor Insira seu Login e Senha."); out.println("<BR> <FORM METHOD = POST>"); out.println("Login: <INPUT TYPE=TEXT NAME=login"); out.println("><BR> Senha:<INPUT TYPE= PASSWORD NAME=senha"); out.println("><INPUT TYPE=SUBMIT VALUE=logar"); out.println("></form>"); out.println("</body>"); out.println("</html>"); } finally { out.close(); }
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
sendLoginForm(response, false);
}public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String login = request.getParameter(“login”);
String senha = request.getParameter(“senha”);
if(login != null && senha!= null &&
login.equals(“patrick”) && senha.equals(“jsp”)){
response.sendRedirect(“http://www.metroval.com.br”);
}
else{
sendLoginForm(response , true);
}
}public String getServletInfo() {
return “Short description”;
}
}[/code]
O outro problema e que eu add imagens no pelo netbeans e sempre quando eu compilo nao aparece! Tem que colocar em algum lugar especifico? colocar o endereco do arquivo em algum lugar ?
Valeew Obrigado