Hello
I have a jsp and a bean :
----------------------------------------------------------------
jsp
----------------------------------------------------------------
<jsp:useBean id ="test" scope="page" class="test_tbe" />
<jsp:setProperty name="test" property="name" param="p_name"/>
<jsp:setProperty name="test" property="email" param="p_email"/>
<jsp:setProperty name="test" property="age" param="p_age"/>
<HTML>
<BODY>
<BR><BR>
Hello
<BR>
please enter your name and your email ...
<FORM METHOD="GET">
Name :
<INPUT TYPE="text" name="p_name">
<BR> Email :
<INPUT TYPE="text" name="p_email">
<BR> Age :
<INPUT TYPE="text" name="p_age">
<BR><BR>
<INPUT TYPE="SUBMIT">
<% if ( request.getParameter( "p_name" ) != null ) { %>
<BR> <BR>
Nom :
<jsp:getProperty name="test" property="name" />
<BR>
Age :
<jsp:getProperty name="test" property="age" />
<% } %>
</FORM>
</BODY>
</HTML>
----------------------------------------------------------------
bean
----------------------------------------------------------------
import java.util.*;
public class test_tbe
{
private String name=null,email=null;
private int age;
public test_tbe()
{
}
public String getName()
{
return email;
}
public int getAge()
{
return age;
}
public void setName(String p_name)
{
name = new String(p_name);
}
public void setEmail(String p_email)
{
email = new String(p_email);
}
public void setAge(int p_age)
{
age = p_age;
}
}
It's work but when I enter a String for the age, its generates an error.
So I change the code in the bean with :
public void setAge(String p_age)
{
try {
age = Integer.parseInt(p_age);
}
catch(Exception e)
{
age=24; // by default
}
}
it seems to be correct but when I try this example, I have this error :
org.apache.jasper.JasperException: Can't find a method to write property
'age' in a bean of type 'test_tbe'
at
org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper(JspRuntimeLibra
ry.java:212)
at
_0002ftest_0005ftbe_0002ejsptest_0005ftbe_jsp_0._jspService(_0002ftest_0005f
tbe_0002ejsptest_0005ftbe_jsp_0.java:97)
at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
va:177)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:210)
at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
Can you help me ??
thanks
Thierry
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets