Ecco:
il bean
package beans;
import java.io.*;
import java.util.*;
public class Person implements Serializable
{
private String nome;
private String cognome;
private String username;
private String password;
private String email;
public String getNome()
{
return nome;
}
public void setNome(String s)
{
nome = s;
}
public String getCognome()
{
return cognome;
}
public void setCognome(String s)
{
cognome = s;
}
public String getUsername()
{
return username;
}
public void setUsername(String s)
{
username = s;
}
public String getPassword()
{
return password;
}
public void setPassword(String s)
{
password = s;
}
public boolean NameValid() {
boolean isValid = false;
if (nome != null) {
isValid = true;
}
return isValid;
}
}
La pagina con il form
<%@page contentType="text/html"%>
<%@ page language="java" %>
<html>
<head><title>Registrazione</title></head>
<body>
<%-- <jsp:useBean id="beanInstanceName" scope="session" class="package.class" /> --%>
<%-- <jsp:getProperty name="beanInstanceName" property="propertyName" /> --%>
<jsp:useBean id="miobean" class="beans.Person" scope="session" />
<h1>Inserisci i tuoi dati</h1>
<%--<jsp:getProperty name="bean" property="nome" />--%>
<form action="visualizzabean.jsp" method="post" >
<table>
<td>Nome</td>
<td> <input type="text" name="nome"></td>
<tr>
<td>Cognome</td>
<td> <input type="text" name="cognome"></td>
</tr>
<tr>
<td>Username</td>
<td> <input type="text" name="username"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td>E-Mail</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>Tipo di utilizzo</td>
<td>
<input type="radio" name="tipo" value='privato' checked>privato
<input type="radio" name="tipo" value='azienda' >azienda
</td>
</tr>
<%--<jsp:setProperty name="miobean" property="nome" value="m" />--%>
<td>
<input type="submit" value="INVIA" onsubmit="visualizzabean.jsp">
</td>
</body>
</html>
la pagina con il get
<%@page contentType="text/html"%>
<html>
<head><title>JSP Page</title></head>
<body>
<jsp:useBean id="miobean"
scope="request"
class="beans.Person">
<jsp:setProperty name="miobean" property="*" />
</jsp:useBean>
<%--<%=bean.getNome()%>--%>
<jsp:getProperty name = "miobean" property = "nome" />
<%-- <jsp:useBean id="beanInstanceName" scope="session" class="package.class" /> --%>
<%-- <jsp:getProperty name="beanInstanceName" property="propertyName" /> --%>
</body>
</html>
Fammi sapere, io non ne riesco a venire a capo.
Grazie!!!!

Rispondi quotando