java - jsp bean cannot find any information on property -
i can try write jsp javabean . receive error message eclipse console : cannot find information on property 'uomo' in bean of type 'conta.contagenere' . think wrote well, there don't know or can't see! run in eclipse server inside eclipse .
i have 3 files: form, 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 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 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 */ public void setuomo(int i){ uomo+=i; } /** * * @param */ 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>
this folders of project in 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
this error message console eclipse when starts forms:
mar 21, 2015 11:24:14 org.apache.tomcat.util.digester.setpropertiesrule begin avvertenza: [setpropertiesrule]{server/service/engine/host/context} setting property 'source' 'org.eclipse.jst.jee.server:esercizio_13_x' did not find matching property. .... .... .... mar 21, 2015 11:24:16 org.apache.catalina.core.standardcontext loadonstartup grave: servlet [benvenuto3] in web application [/esercizio_13_x] threw load() exception org.apache.jasper.jasperexception: cannot find information on property 'uomo' in bean of type 'conta.contagenere' @ org.apache.jasper.runtime.jspruntimelibrary.getreadmethod(jspruntimelibrary.java:804) @ org.apache.jasper.compiler.generator$generatevisitor.visit(generator.java:1158) @ org.apache.jasper.compiler.node$getproperty.accept(node.java:1122) @ org.apache.jasper.compiler.node$nodes.visit(node.java:2376) @ org.apache.jasper.compiler.node$visitor.visitbody(node.java:2428) @ org.apache.jasper.compiler.node$visitor.visit(node.java:2434) @ org.apache.jasper.compiler.node$root.accept(node.java:464) @ org.apache.jasper.compiler.node$nodes.visit(node.java:2376) @ org.apache.jasper.compiler.generator.generate(generator.java:3594) @ org.apache.jasper.compiler.compiler.generatejava(compiler.java:250) @ org.apache.jasper.compiler.compiler.compile(compiler.java:356) @ org.apache.jasper.compiler.compiler.compile(compiler.java:336) @ org.apache.jasper.compiler.compiler.compile(compiler.java:323) @ org.apache.jasper.jspcompilationcontext.compile(jspcompilationcontext.java:570) @ org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:356) @ org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:396) @ org.apache.jasper.servlet.jspservlet.init(jspservlet.java:138) @ org.apache.catalina.core.standardwrapper.initservlet(standardwrapper.java:1231) @ org.apache.catalina.core.standardwrapper.loadservlet(standardwrapper.java:1144) @ org.apache.catalina.core.standardwrapper.load(standardwrapper.java:1031) @ org.apache.catalina.core.standardcontext.loadonstartup(standardcontext.java:4909) @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5196) @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150) @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1409) @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1399) @ java.util.concurrent.futuretask.run(unknown source) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ java.lang.thread.run(unknown source) mar 21, 2015 11:24:16 org.apache.coyote.abstractprotocol start informazioni: starting protocolhandler ["http-nio-8080"] mar 21, 2015 11:24:16 org.apache.coyote.abstractprotocol start informazioni: starting protocolhandler ["ajp-nio-8009"] mar 21, 2015 11:24:16 org.apache.catalina.startup.catalina start informazioni: server startup in 1510 ms
thank in advance helps me.
i tried problem after changing html elements working fine.
first of map jsp beans both html elements name , bean class property want map should same.
in jsp page renamed fields uomo & donna. both should same mapping bean component
in jsp page renamed sesso uomo , added {} if else blocks.
<!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 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 questa applicazione! <br> verrai rediretto su un altra pagina ... </h1> </body> </html>
Comments
Post a Comment