i tried this under the tomcat i am getting output as
Second page
but mock says that there will be compile time error.
i dont know why i am getting this output how getproperty standerd action is searching the property.
please clarify this to me I am going to take the test 6th of this month.
M Jairam
Greenhorn
Joined: Nov 04, 2005
Posts: 22
posted
0
Amithkumar: The following is my observation:
1. If you don't specify the scope attribute in <jsp:useBean..>, then the scope defaults to "page". (Ref: HFSJ top of page 355). So, in the situation where you don't have a scope attribute with <jsp:useBean id="person" type="foo.person"/> the scope defaults to page, and the statement is same as having: <jsp:useBean id="person" type="foo.person" scope="page"/> In summary, it will not search or find in any other scope (unlike an EL attribute where it will search in all four scopes).
You can try this with the following example:
<%@ page import="foo.*" %> <html> <body>
<% person lclperson = new foo.person(); lclperson.setName("YourName"); pageContext.getSession().setAttribute("person", lclperson);
public void setName(String inname) { name = inname; }
}
2. For the second question, your observation is the same as mine, that is it does print "Second Page" - this only if I ignore the following syntax error in your post: <jsp:getProperty name="bean" property="name"> is not properly terminated, if above line is used as is, you will get compile error.
Hope this helps.
Narendra:
What is the meaning of your reply above? I did not get it. "It will not search in all scope." is correct. However, the next sentance you mention "class/beanName" - what has this got to do with scope - I don't think scope depends on these attributes in anyway. Also, what did you mean by "given scope"? May be you ment the default scope - "page"...
Richard Green
Ranch Hand
Joined: Aug 25, 2005
Posts: 536
posted
0
<jsp:useBean id="person" type="foo.person"/>
you would get a big fat instantiation error if u dont have a bean called "person" in ur page scope.(class attribute is not specified in the tag)
MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.