Galera, elaborei este código para poder cadastrar um usuario.
Ele esta funcionando corretamente. O que tenho que fazer agora é saber como posso modificar e como posso remover esses dados da memoria do tomcat!!
Alguem pode me ajudar??
Cadastro de Usuario
<%@ page import=“java.util., p1.” %>
Página de Criação <% Date dtNasc, dtTer; Calendar cal, cal2;String nome = request.getParameter("nome");
String email = request.getParameter("email");
String cargo = request.getParameter("cargo");
String strDia = request.getParameter("dia");
String strMes = request.getParameter("mes");
String strAno = request.getParameter("ano");
String nomeT = request.getParameter("nomeT");
String desc = request.getParameter("desc");
String strDiaT = request.getParameter("diaT");
String strMesT = request.getParameter("mesT");
String strAnoT = request.getParameter("anoT");
String statusStr = request.getParameter("status");
String strFer = request.getParameter("ferias");
int status;
if (statusStr.equals(“normal”)) {
status = Tarefa.NORMAL;
} else if (statusStr.equals(“urgente”)) {
status = Tarefa.URGENTE;
} else {
status = Tarefa.IMEDIATA;
}
if ( (nome == null) || (email == null) || (cargo == null) || (strDia == null) || (strMes == null) || (strAno == null)
|| (nomeT == null) || (desc == null)|| (strDiaT == null) || (strMesT == null) || (strAnoT == null)) {%>
<jsp:forward page="/criacaoFalhou.html"/>
<%
}else {
boolean fer = strFer.equals("true") ? true : false;
int dia = Integer.valueOf(strDia).intValue();
int mes = Integer.valueOf(strMes).intValue();
int ano = Integer.valueOf(strAno).intValue();
int diaT = Integer.valueOf(strDiaT).intValue();
int mesT = Integer.valueOf(strMesT).intValue();
int anoT = Integer.valueOf(strAnoT).intValue();
cal = new GregorianCalendar(ano, mes, dia);
dtNasc = cal.getTime();
cal2 = new GregorianCalendar(anoT, mesT, diaT);
dtTer = cal2.getTime();
Tarefa tarefa = new Tarefa(nomeT, desc, dtTer, status);
Usuario usuario = new Usuario (nome, email, cargo, dtNasc, fer);
GerenciadorUsuario.adicionarUsuario(usuario);
GerenciadorTarefa.adicionarTarefa(tarefa);
%>
Estes são os USUÁRIOS e TAREFAS cadastrados no sistema:
| Nome do Usuário | Cargo | Nome da tarefa | Descrição | Status | |
| <%= u.getNome() %> | <%= u.getEmail() %> | <%= u.getCargo() %> | <%= t.getNomeT() %> | <%= t.getDesc() %> | <%= t.getStatus() %> |
ARQUIVO .JAVA QUE TRATA O USUARIO
package p1;
import java.util.Date;
public class Usuario {
private Tarefa tarefa;
private String nome;
private String email;
private String cargo;
private Date dtNasc;
private boolean fer;
public Usuario (String nome, String email, String cargo,Date dtNasc, boolean fer ) {
this.nome = nome;
this.email = email;
this.cargo = cargo;
this.dtNasc = new Date();
this.fer = fer;
}
public String getNome() {
return this.nome;
}
public String getEmail () {
return this.email;
}
public String getCargo () {
return this.cargo;
}
public Date getDtNasc () {
return this.dtNasc;
}
public boolean getFer () {
return this.fer;
}
public Tarefa getTarefa() {
return this.tarefa;
}
public void setNome(String nome) {
this.nome = nome;
}
public void setEmail(String email) {
this.email = email;
}
public void setCargo(String cargo) {
this.cargo = cargo;
}
public void setDtNasc(Date dtNasc){
this.dtNasc = dtNasc;
}
public void setTarefa(Tarefa tarefa){
this.tarefa = tarefa;
}
public void setFer (boolean fer) {
this.fer = fer;
}
}
ARQUIVO .JAVA QUE TRATA A TAREFA
package p1;
import java.util.Date;
public class Tarefa
{
public static final int NORMAL = 0;
public static final int URGENTE = 1;
public static final int IMEDIATA = 2;
private int status;
private Date dtTer;
private String nomeT;
private String desc;
public Tarefa(String nomeT, String desc, Date dtTer, int status){
this.nomeT = nomeT;
this.desc = desc;
this.dtTer = new Date();
this.status = status;
}
public Tarefa() {
this.status = NORMAL;
}
public String getNomeT() {
return this.nomeT;
}
public String getDesc() {
return this.desc;
}
public Date getDtTer () {
return this.dtTer;
}
public int getStatus () {
return this.status;
}
public void setNomeT(String nomeTar) {
this.nomeT = nomeTar;
}
public void setDesc(String descTar) {
this.desc = descTar;
}
public void setDtTer(Date dtTer){
this.dtTer = dtTer;
}
public void setStatus(int tipo) {
this.status = tipo;
}
}
ARQUIVO .JAVA QUE TRATA O VETOR DE USUARIOS
package p1;
import java.util.*;
public class GerenciadorUsuario
{
private static Vector usuarios = new Vector();
public static void adicionarUsuario(Usuario novoUsuario) {
usuarios.add(novoUsuario);
}
public static Vector getUsuarios() {
return usuarios;
}
}
ARQUIVO JAVA QUE TRATA O VETOR DE TAREFAS
package p1;
import java.util.*;
public class GerenciadorTarefa
{
private static Vector tarefas = new Vector();
public static void adicionarTarefa(Tarefa novaTarefa) {
tarefas.add(novaTarefa);
}
public static Vector getTarefas() {
return tarefas;
}
}
Preciso de Ajuda Amigos