Escolar Documentos
Profissional Documentos
Cultura Documentos
Introdução
Código-fonte
Usuario.java
package com.plixsite.modelo;
public Usuario(){
super();
}
}
ServletControle.java
package com.plixsite.controle;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.plixsite.modelo.Usuario;
public ServletControle() {
super();
}
login.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-
8859-1">
<title>Exemplo MVC</title>
</head>
<body>
<h1>Model-View-Controller</h1>
<h3>Informe os dados solicitados:</h3>
<form action="ServletControle">
Login: <input type="text" name="login" /><br />
Senha: <input type="text" name="senha" /><br />
<input type="submit" value="Enviar" />
<input type="reset" value="Limpar" />
</form>
</body>
</html>
saudacao.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
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>Exemplo MVC</title>
</head>
<body>
<h1>Model-View-Controller</h1>
<jsp:useBean
id="usuario"
type="com.plixsite.modelo.Usuario"
scope="session"
/>
Oi,
<jsp:getProperty
name="usuario"
property="login" />
<jsp:getProperty
name="usuario"
property="senha" />
</body>
</html>
Baixe o projeto:
http://www.plixsite.com/downloads/eclipse-mvc.zip