The contents of beans class are as follows:-
package projsp;
public class trying
{
private
String name;
private int age;
public void setName(String n)
{
name=n;
}
public void setAge(int a)
{
age=a;
}
public int getAge()
{
return age;
}
public String getName()
{
return name;
}
}
The contents of test.jsp file are as follows:
<%@ page language="java" import="projsp.*" %>
<
jsp:useBean id="test" class="projsp.trying" />
<html>
The Name is <getProperty name="test" property="name" />
The Age is < jsp:getProperty name="test" property="age" />
</html>
If a user types in
http://servername:8080/test.jsp?name=Anand&age=22 the out put is
The correct answer is The Name is null and The Age is null as the properties are not
set prior to accessing them,adding <jsp:setProperty name="test" property="*">
would give output as The Name is Anand and The Age is 22
<b>why does'nt it print nae is null and age =0??</b>