jsp bean 在 属性 上找不到任何信息
jsp bean cannot find any information on property
我可以尝试用 javabean 写一个 jsp 。但是我从 eclipse 控制台收到一条错误消息:Cannot find any information on 属性 'Uomo' in a bean of type 'conta.Contagenere' 。我觉得我写的很好,但是有些东西我不知道或者我看不到!
我 运行 全部在 Eclipse 中,服务器在 eclipse 中。
我有 3 个文件:表单、jsp 和 java。还有 web.xml.
Form_13_6.html
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Inserisci dati...</title>
</head>
<body>
<form action="http://127.0.0.1:8080/Esercizio_13_x/benvenuto3" method="post">
<p>
Nome: <INPUT type="text" name="nome" ><br>
Cognome: <INPUT type="text" name="cognome" ><br>
Sesso: <INPUT type="radio" name="sesso" value="Maschio">Maschio<INPUT type="radio" name="sesso" value="Femmina">Femmina<br>
Età: <INPUT type="number" name="anni" ><br>
<input type="submit" value="Invio"> <input type="reset" value="Cancella">
</p>
</form>
</body>
</html>
Form_13_6a.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="conta.Contagenere" %>
<%-- Faccio avanzare i counter --%>
<jsp:useBean id="lcontagenere" class="conta.Contagenere" scope="application"></jsp:useBean>
<%
if(request.getParameter("sesso").compareTo("Maschio") == 0)
%>
<jsp:setProperty property="Uomo" name="lcontagenere" value="1"/>
<%
else
%>
<jsp:setProperty property="Donna" name="lcontagenere" value="1"/>
<%-- Creazione dinamica della pagina --%>
<!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>Benvenuto...</title>
</head>
<body>
<h1>
<%=
request.getParameter("nome") + ", sei " +
((request.getParameter("sesso").compareTo("Maschio") == 0) ? "l'uomo n." : "la donna n.")
%>
<%
if(request.getParameter("sesso").compareTo("Maschio") == 0)
%>
<jsp:getProperty property="Uomo" name="lcontagenere"/>
<%
else
%>
<jsp:getProperty property="Donna" name="lcontagenere"/>
che si registra a questa applicazione!
<br>
Verrai rediretto su un altra pagina ...
<jsp:forward page="http://127.0.0.1:8080/Esercizio_13_x/benvenuto3b" ></jsp:forward>
</h1>
</body>
</html>
Contagenere.java
/**
*
*/
package conta;
/**
* @author Gabriele
*
*/
public class Contagenere {
/**
*
*/
private int uomo;
/**
*
*/
private int donna;
/**
*
*/
public Contagenere(){
}
/**
*
* @return
*/
public int getUomo(){ return uomo; }
/**
*
* @return
*/
public int getDonna(){ return donna; }
/**
*
* @param i
*/
public void setUomo(int i){ uomo+=i; }
/**
*
* @param i
*/
public void setDonna(int i){ donna+=i; }
}
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<display-name>Esercizio_13_x</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>sommajsp</servlet-name>
<jsp-file>/Esercizio_13_1.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>sommajsp</servlet-name>
<url-pattern>/sommajsp</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>benvenuto</servlet-name>
<jsp-file>/Esercizio_13_3.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>benvenuto</servlet-name>
<url-pattern>/benvenuto</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>contaaccessihost</servlet-name>
<jsp-file>/Esercizio_13_4.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>contaaccessihost</servlet-name>
<url-pattern>/contaaccessihost</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>benvenuto2</servlet-name>
<jsp-file>/Esercizio_13_5.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>benvenuto2</servlet-name>
<url-pattern>/benvenuto2</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>benvenuto3</servlet-name>
<jsp-file>/Esercizio_13_6a.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>benvenuto3</servlet-name>
<url-pattern>/benvenuto3</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>benvenuto3b</servlet-name>
<jsp-file>/Esercizio_13_6b.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>benvenuto3b</servlet-name>
<url-pattern>/benvenuto3b</url-pattern>
</servlet-mapping>
</web-app>
这是我在 eclipse 中项目的文件夹:
D:\Dropbox\CodiciProgettiSoftware\Eclipse\workspacePSR\Esercizio_13_x>tree /f
Elenco del percorso delle cartelle per il volume Dati
Numero di serie del volume: 2831-E096
D:.
│ .classpath
│ .project
│
├───.settings
│ .jsdtscope
│ org.eclipse.jdt.core.prefs
│ org.eclipse.wst.common.component
│ org.eclipse.wst.common.project.facet.core.xml
│ org.eclipse.wst.jsdt.ui.superType.container
│ org.eclipse.wst.jsdt.ui.superType.name
│
├───build
│ └───classes
│ └───conta
│ Contagenere.class
│
├───src
│ └───conta
│ Contagenere.java
│
└───WebContent
│ Esercizio_13_1.jsp
│ Esercizio_13_2.jsp
│ Esercizio_13_3.jsp
│ Esercizio_13_4.jsp
│ Esercizio_13_5.jsp
│ Esercizio_13_6a.jsp
│ Esercizio_13_6b.jsp
│ Form_13_1.html
│ Form_13_3.html
│ Form_13_5.html
│ Form_13_6.html
│
├───META-INF
│ MANIFEST.MF
│
└───WEB-INF
│ web.xml
│
└───lib
这是启动表单时来自控制台 eclipse 的错误消息:
mar 21, 2015 11:24:14 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
AVVERTENZA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Esercizio_13_x' did not find a matching property.
.... .... ....
mar 21, 2015 11:24:16 AM org.apache.catalina.core.StandardContext loadOnStartup
GRAVE: Servlet [benvenuto3] in web application [/Esercizio_13_x] threw load() exception
org.apache.jasper.JasperException: Cannot find any information on property 'Uomo' in a bean of type 'conta.Contagenere'
at org.apache.jasper.runtime.JspRuntimeLibrary.getReadMethod(JspRuntimeLibrary.java:804)
at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1158)
at org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1122)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:464)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Generator.generate(Generator.java:3594)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:250)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:570)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:356)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
at org.apache.jasper.servlet.JspServlet.init(JspServlet.java:138)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1031)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4909)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
mar 21, 2015 11:24:16 AM org.apache.coyote.AbstractProtocol start
INFORMAZIONI: Starting ProtocolHandler ["http-nio-8080"]
mar 21, 2015 11:24:16 AM org.apache.coyote.AbstractProtocol start
INFORMAZIONI: Starting ProtocolHandler ["ajp-nio-8009"]
mar 21, 2015 11:24:16 AM org.apache.catalina.startup.Catalina start
INFORMAZIONI: Server startup in 1510 ms
提前感谢任何帮助我的人。
我在更改 html 元素后尝试了你的问题,它工作正常。
首先要映射 jsp bean html 元素名称和我们要映射到的 bean class 属性 应该相同。
在 JSP 页面中,我将您的字段重命名为 uomo & donna。两者都应该与映射 bean 组件相同
在您的 JSP 页面中,我还将 sesso 重命名为 uomo 并为 if else 块添加了 {}。
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Inserisci dati...</title>
</head>
<body>
<form action="Esercizio_13_6a.jsp" method="post">
<p>
Nome: <INPUT type="text" name="nome" ><br>
Cognome: <INPUT type="number" name="cognome" ><br>
Sesso: <INPUT type="radio" name="uomo" value="Maschio">Maschio<INPUT type="radio" name="sesso" value="Femmina">Femmina<br>
Età: <INPUT type="number" name="donna" ><br>
<input type="submit" value="Invio"> <input type="reset" value="Cancella">
</p>
</form>
</body>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="conta.Contagenere" %>
<%-- Faccio avanzare i counter --%>
<jsp:useBean id="lcontagenere" class="conta.Contagenere" scope="application"></jsp:useBean>
<%
if(request.getParameter("uomo").compareTo("Maschio") == 0)
{
%>
<jsp:setProperty property="uomo" name="lcontagenere" value="1"/>
<%}
else{
%>
<jsp:setProperty property="donna" name="lcontagenere" value="1"/>
<% }%>
<%-- Creazione dinamica della pagina --%>
<!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>Benvenuto...</title>
</head>
<body>
<h1>
<%=
request.getParameter("nome") + ", sei " +
((request.getParameter("uomo").compareTo("Maschio") == 0) ? "l'uomo n." : "la donna n.")
%>
<%
if(request.getParameter("uomo").compareTo("Maschio") == 0)
{ %>
<jsp:getProperty property="uomo" name="lcontagenere"/>
<% }
else
{ %>
<jsp:getProperty property="donna" name="lcontagenere"/>
<% } %>
che si registra a questa applicazione!
<br>
Verrai rediretto su un altra pagina ...
</h1>
</body>
</html>
我可以尝试用 javabean 写一个 jsp 。但是我从 eclipse 控制台收到一条错误消息:Cannot find any information on 属性 'Uomo' in a bean of type 'conta.Contagenere' 。我觉得我写的很好,但是有些东西我不知道或者我看不到! 我 运行 全部在 Eclipse 中,服务器在 eclipse 中。
我有 3 个文件:表单、jsp 和 java。还有 web.xml.
Form_13_6.html
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Inserisci dati...</title>
</head>
<body>
<form action="http://127.0.0.1:8080/Esercizio_13_x/benvenuto3" method="post">
<p>
Nome: <INPUT type="text" name="nome" ><br>
Cognome: <INPUT type="text" name="cognome" ><br>
Sesso: <INPUT type="radio" name="sesso" value="Maschio">Maschio<INPUT type="radio" name="sesso" value="Femmina">Femmina<br>
Età: <INPUT type="number" name="anni" ><br>
<input type="submit" value="Invio"> <input type="reset" value="Cancella">
</p>
</form>
</body>
</html>
Form_13_6a.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="conta.Contagenere" %>
<%-- Faccio avanzare i counter --%>
<jsp:useBean id="lcontagenere" class="conta.Contagenere" scope="application"></jsp:useBean>
<%
if(request.getParameter("sesso").compareTo("Maschio") == 0)
%>
<jsp:setProperty property="Uomo" name="lcontagenere" value="1"/>
<%
else
%>
<jsp:setProperty property="Donna" name="lcontagenere" value="1"/>
<%-- Creazione dinamica della pagina --%>
<!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>Benvenuto...</title>
</head>
<body>
<h1>
<%=
request.getParameter("nome") + ", sei " +
((request.getParameter("sesso").compareTo("Maschio") == 0) ? "l'uomo n." : "la donna n.")
%>
<%
if(request.getParameter("sesso").compareTo("Maschio") == 0)
%>
<jsp:getProperty property="Uomo" name="lcontagenere"/>
<%
else
%>
<jsp:getProperty property="Donna" name="lcontagenere"/>
che si registra a questa applicazione!
<br>
Verrai rediretto su un altra pagina ...
<jsp:forward page="http://127.0.0.1:8080/Esercizio_13_x/benvenuto3b" ></jsp:forward>
</h1>
</body>
</html>
Contagenere.java
/**
*
*/
package conta;
/**
* @author Gabriele
*
*/
public class Contagenere {
/**
*
*/
private int uomo;
/**
*
*/
private int donna;
/**
*
*/
public Contagenere(){
}
/**
*
* @return
*/
public int getUomo(){ return uomo; }
/**
*
* @return
*/
public int getDonna(){ return donna; }
/**
*
* @param i
*/
public void setUomo(int i){ uomo+=i; }
/**
*
* @param i
*/
public void setDonna(int i){ donna+=i; }
}
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<display-name>Esercizio_13_x</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>sommajsp</servlet-name>
<jsp-file>/Esercizio_13_1.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>sommajsp</servlet-name>
<url-pattern>/sommajsp</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>benvenuto</servlet-name>
<jsp-file>/Esercizio_13_3.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>benvenuto</servlet-name>
<url-pattern>/benvenuto</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>contaaccessihost</servlet-name>
<jsp-file>/Esercizio_13_4.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>contaaccessihost</servlet-name>
<url-pattern>/contaaccessihost</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>benvenuto2</servlet-name>
<jsp-file>/Esercizio_13_5.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>benvenuto2</servlet-name>
<url-pattern>/benvenuto2</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>benvenuto3</servlet-name>
<jsp-file>/Esercizio_13_6a.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>benvenuto3</servlet-name>
<url-pattern>/benvenuto3</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>benvenuto3b</servlet-name>
<jsp-file>/Esercizio_13_6b.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>benvenuto3b</servlet-name>
<url-pattern>/benvenuto3b</url-pattern>
</servlet-mapping>
</web-app>
这是我在 eclipse 中项目的文件夹:
D:\Dropbox\CodiciProgettiSoftware\Eclipse\workspacePSR\Esercizio_13_x>tree /f
Elenco del percorso delle cartelle per il volume Dati
Numero di serie del volume: 2831-E096
D:.
│ .classpath
│ .project
│
├───.settings
│ .jsdtscope
│ org.eclipse.jdt.core.prefs
│ org.eclipse.wst.common.component
│ org.eclipse.wst.common.project.facet.core.xml
│ org.eclipse.wst.jsdt.ui.superType.container
│ org.eclipse.wst.jsdt.ui.superType.name
│
├───build
│ └───classes
│ └───conta
│ Contagenere.class
│
├───src
│ └───conta
│ Contagenere.java
│
└───WebContent
│ Esercizio_13_1.jsp
│ Esercizio_13_2.jsp
│ Esercizio_13_3.jsp
│ Esercizio_13_4.jsp
│ Esercizio_13_5.jsp
│ Esercizio_13_6a.jsp
│ Esercizio_13_6b.jsp
│ Form_13_1.html
│ Form_13_3.html
│ Form_13_5.html
│ Form_13_6.html
│
├───META-INF
│ MANIFEST.MF
│
└───WEB-INF
│ web.xml
│
└───lib
这是启动表单时来自控制台 eclipse 的错误消息:
mar 21, 2015 11:24:14 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
AVVERTENZA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Esercizio_13_x' did not find a matching property.
.... .... ....
mar 21, 2015 11:24:16 AM org.apache.catalina.core.StandardContext loadOnStartup
GRAVE: Servlet [benvenuto3] in web application [/Esercizio_13_x] threw load() exception
org.apache.jasper.JasperException: Cannot find any information on property 'Uomo' in a bean of type 'conta.Contagenere'
at org.apache.jasper.runtime.JspRuntimeLibrary.getReadMethod(JspRuntimeLibrary.java:804)
at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1158)
at org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1122)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:464)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Generator.generate(Generator.java:3594)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:250)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:570)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:356)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
at org.apache.jasper.servlet.JspServlet.init(JspServlet.java:138)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1031)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4909)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
mar 21, 2015 11:24:16 AM org.apache.coyote.AbstractProtocol start
INFORMAZIONI: Starting ProtocolHandler ["http-nio-8080"]
mar 21, 2015 11:24:16 AM org.apache.coyote.AbstractProtocol start
INFORMAZIONI: Starting ProtocolHandler ["ajp-nio-8009"]
mar 21, 2015 11:24:16 AM org.apache.catalina.startup.Catalina start
INFORMAZIONI: Server startup in 1510 ms
提前感谢任何帮助我的人。
我在更改 html 元素后尝试了你的问题,它工作正常。
首先要映射 jsp bean html 元素名称和我们要映射到的 bean class 属性 应该相同。
在 JSP 页面中,我将您的字段重命名为 uomo & donna。两者都应该与映射 bean 组件相同
在您的 JSP 页面中,我还将 sesso 重命名为 uomo 并为 if else 块添加了 {}。
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Inserisci dati...</title>
</head>
<body>
<form action="Esercizio_13_6a.jsp" method="post">
<p>
Nome: <INPUT type="text" name="nome" ><br>
Cognome: <INPUT type="number" name="cognome" ><br>
Sesso: <INPUT type="radio" name="uomo" value="Maschio">Maschio<INPUT type="radio" name="sesso" value="Femmina">Femmina<br>
Età: <INPUT type="number" name="donna" ><br>
<input type="submit" value="Invio"> <input type="reset" value="Cancella">
</p>
</form>
</body>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="conta.Contagenere" %>
<%-- Faccio avanzare i counter --%>
<jsp:useBean id="lcontagenere" class="conta.Contagenere" scope="application"></jsp:useBean>
<%
if(request.getParameter("uomo").compareTo("Maschio") == 0)
{
%>
<jsp:setProperty property="uomo" name="lcontagenere" value="1"/>
<%}
else{
%>
<jsp:setProperty property="donna" name="lcontagenere" value="1"/>
<% }%>
<%-- Creazione dinamica della pagina --%>
<!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>Benvenuto...</title>
</head>
<body>
<h1>
<%=
request.getParameter("nome") + ", sei " +
((request.getParameter("uomo").compareTo("Maschio") == 0) ? "l'uomo n." : "la donna n.")
%>
<%
if(request.getParameter("uomo").compareTo("Maschio") == 0)
{ %>
<jsp:getProperty property="uomo" name="lcontagenere"/>
<% }
else
{ %>
<jsp:getProperty property="donna" name="lcontagenere"/>
<% } %>
che si registra a questa applicazione!
<br>
Verrai rediretto su un altra pagina ...
</h1>
</body>
</html>