Question for
Java Beans.
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
Options given are:
1.Name is Anand
Age is 22
2.Name is Null
Age is 0
3.Name is Null
Age is Null
4.It gives a compilation error as the roperties are not set prior to retrieving them
The correct answer given is 3.
But When I tries the above example on my PC using tomcat4 I got the result as
The Name is
The Age is 0
so What exactly is the correct answer? is it 2? if I consider blank is null?
thanks,
Trupti
[ November 09, 2002: Message edited by: trupti nigam ]