MyUseBean.jsp
<%@ page language="java" import="com.mypackage.MyBean" %>
<
jsp:useBean id="myBean" class="MyBean"/>
<jsp:setProperty name="myBean" property="myProperty" value="<%=request.getParameter("sentProperty")%>"/>
<jsp:getProperty name="myBean" property="myProperty"/>
MyBean.java
Package com.mypackage;
Public class MyBean
{
private
String myProperty;
public MyBean()
{
this("initialValue");
}
public MyBean(String myProperty)
{
this.myProperty= myProperty;}
public void setMyProperty(String myProperty)
{
this. MyProperty= myProperty;
}
public String getMyProperty()
{
return myProperty;
}
}
Which of the following is the result produced when MyUseBean.jsp is accessed with the URL MyUseBean.jsp?sentProperty= (Without any value provided to sentProperty)
A.Runtime Error
B.Prints "null"
C.Prints "initialValue"
D.None Of the Above
This is a question from Mock Exams.
My Ans is: B
But the correct Ans is :C
Can anyone let me know the explanation?
Thanks