Ola......
Alguem sabe de uma apostila JSP...... "me corrigem qualquer coisa".....como fazer uma pagina usando os atributos da minha classe. Por exemplo eu tenho uma classe de cadastro de funcionario , mas na hora de subir pra pagina eu nao sei como direcionar os objetos para classe cadastro de funcionario.
eu fiz assim....
[b]package br.com.exercicio;
public class Cadastro {
protected String nome;
protected String endereco;
protected int telefone;
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getEndereco() {
return endereco;
}
public void setEndereco(String endereco) {
this.endereco = endereco;
}
public int getTelefone() {
return telefone;
}
public void setTelefone(int telefone) {
this.telefone = telefone;
}
public void MostraCadastro() {
System.out.println(getNome() + "\n" + getEndereco() + "\n"
+ getTelefone());
}
}[/b]
na web.xml eu coloquei assim
[b]<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>jspteste</display-name>
<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>
<servlet>
<servlet-name>cadastro</servlet-name>
<servlet-class>br.com.exercicio.Cadastro</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>cadastro</servlet-name>
<url-pattern>/cad</url-pattern>
</servlet-mapping>
</web-app>[/b]
e na minha .jsp eu coloquei assim
[b]
<%@ 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>Insert title here</title>
</head>
<body>
<form action="testa-adiciona" method="post">
Nome :<input type="text" name="nome"/></br>
Endereço : <input type="text" name="endereco"/></br>
Telefone : <input type="text" name="telefone"/></br>
<input type="submit" value="Enviar"/>
</form>
</body>
</html>[/b]
pessoal desculpe a minha ruindade hehehe, mas muito obrigado.