Peter Du

Greenhorn
+ Follow
since Oct 29, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Peter Du

Hi,
Today I completed my SCBCD exam and scored 95% . Here is my preparation.
1. Read HFE book once and do all the exercise and mock exam.
2. Mikalai Zaikin's SCBCD Guide (http://java.boot.by/bcd-guide).
3. Read Valentin Crettaz's cheat sheets several times (http://www.valoxo.ch/jr/cheatsheets.html).
4. Do the mock exam on http://www.ejbcertificate.com/

Good Luck to every one.
20 years ago
Thanks Keerthi.
I'm not confused about how to use jndi to lookup a remote or local home interface object. My confuse is when compare the process it's easier to understand the process about what's going on when doing the jndi lookup for remote object.
For remote home object jndi lookup, we can conceptually think the following process happened:
1. client tell the name server where to bengin and what object he want.
2. the name server return back a serialized object
3. the client deserialized the object
4. narrow the deserialized object
5. cast
For local home jndi lookup, a similar process will be:
1. client tell the name server where to bengin and what object he want.
2. the name server return back a serialized object
3. the client deserialized the object
4. cast
The problem is in this way the client get a new object, not a reference to the exist local home object! So where the miracle happened?

Thanks.
I'm a little confused about think how jndi lookup for EJBLocalHome interface. When it's for remote home interface (EJBHome) I can think it works this way: the name server return a serializable object (the Stub) to the client, at client side the returned object deserialized, narrowed and cast to a remote interface object and client got it's reference. But for local interface, the name server is the same server and it may be a different server to the EJB container, so it should also return a serializable object when client on the EJB container invoke lookup for a local home interface object, and this object should deserialized on the EJB container and cast to a localhome interface object, if this is right, then the client will get different instance reference after each invoke of lookup, but the problem is the client should get a reference to the REAL EJBLocalHome object on the container, so there should be only one EJBLocalHome object there. Can any please explain how that works out?

Thanks
The following is all the material I used:
1. The great HF Book, read two times, do all the exercise and exam
2. Mock exam on this site, mock exam on www.jdiscuss.com, and mock exam on www.j2eecertificate.com
3. Sample exam on sun site (http://suned.sun.com/US/certification/resources/epractice.html) and Try version exam by www.whizlabs.com/products/scwcd/scwcd.html
4. read the specifications, I read part of the servlet 2.4, JSP 2.0, JSTL 1.1 specification once, mainly things include: standard actions, JSTL core tags, EL(the semantic description is very usefull), tag files, SimpleTag and Classic custom tags, DD diagram(to know all the element in the DD).
5. Read the API document several times.
Please check "JSP.8.3 Semantics of Tag Files" in JSP 2.0 specification, I think when they say TAG scope they really mean it in the JSP page that invoking the tag, but when they say PAGE scope they mean the page for the Tag File. That's what I understand. Can anyone confirm if I understand it right.
I took the exam today and didn't see any of such questions. But maybe just because I didn't encounter one.
This afternoon I passed the SCWCD 1.4 test with 98%. I got 71% with the final mock exam of HF, so I'm a little nervous about the real exam. Then I found everything is OK, after one and half month preparation, study HF two times, one time do all the exercise and example, and second time I just go through and note some important point, the a week before the real exam I took the final mock exam. Before that I do the mock exam of this site and j2eecertificate, jdiscuss. If you just want to pass the exam HF is enough, but if you want to get a high score you need to read the specification and API document. Thanks for HF and this great place and people so I can get valuable information for passing the exam.
Can you show the contents of your wen.xml, and you can try the following web.xml :

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<!-- servlet mappings start -->
<servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>
</web-app>
Sorry, I test the example with Tomcat 5.0.28 and find HF p389 example works fine. So It's a bug of Tomcat 5.0.18 and not the EL functions.

Peter Du
Nov. 26, 2004
I have tried the example in p389 with Tomcat 5.0.18. Here are some problem I encountered and some questions.

First when tested according to the instructions at p88-p390, the container can not find the class, see details error message at "Error 1:"

Then I compare it with the the jsp2 example in tomcat, I found in the tomcat example, even if the method return type is int, but in the TLD they use java.lang.String not int in <function-signature>, after change int to java.lang.String in the taglib of P389 example, I tested again and i got the same error.

After that I try to add a wiered java.lang.Void in <function-signature>, the container can not find the method. see details message at "Error 3"

Finally I change the method in DiceRoller to "public static int rollDice(String name) {...}" ,change the <function-signature> in TLD to "<function-signature>java.lang.String rollDice(java.lang.String)</function-signature>", and change "${mine:rollIt()}" to "${mine:rollIt("2")}" in the JSP, then everything works fine.

My question is the above means that we can not call a method with no arguments with EL?

Thanks in advance.


The following is the errors i got for each case:

Error 1: when use original "<function-signature>int rollDice()</function-signature>"
in TLD file, we got following exception:

org.apache.jasper.JasperException: The class specified in the method signature in TLD for the function mine:rollIt cannot be found.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:94)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:404)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:219)
org.apache.jasper.compiler.Validator$1MapperELVisitor.visit(Validator.java:1405)
org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:163)
org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:234)
org.apache.jasper.compiler.ELNode$Visitor.visit(ELNode.java:275)
org.apache.jasper.compiler.ELNode$Root.accept(ELNode.java:94)
org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:234)
org.apache.jasper.compiler.Validator$ValidateVisitor.getFunctionMapper(Validator.java:1420)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:637)
org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:913)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2230)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2236)
org.apache.jasper.compiler.Node$Root.accept(Node.java:485)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Validator.validate(Validator.java:1515)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:247)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:456)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)



Error 2: when change "<function-signature>int rollDice()</function-signature>" to
"<function-signature>java.lang.String rollDice()</function-signature>"
in TLD file, we got following exception:

org.apache.jasper.JasperException: The class specified in the method signature in TLD for the function mine:rollIt cannot be found.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:94)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:404)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:219)
org.apache.jasper.compiler.Validator$1MapperELVisitor.visit(Validator.java:1405)
org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:163)
org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:234)
org.apache.jasper.compiler.ELNode$Visitor.visit(ELNode.java:275)
org.apache.jasper.compiler.ELNode$Root.accept(ELNode.java:94)
org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:234)
org.apache.jasper.compiler.Validator$ValidateVisitor.getFunctionMapper(Validator.java:1420)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:637)
org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:913)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2230)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2236)
org.apache.jasper.compiler.Node$Root.accept(Node.java:485)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Validator.validate(Validator.java:1515)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:247)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:456)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

Error 3: when change "<function-signature>int rollDice()</function-signature>" to
"<function-signature>java.lang.String rollDice(java.lang.Void)</function-signature>"
in TLD file, we got following exception:

org.apache.jasper.JasperException: Method "rollDice" for function "rollIt" not found in class "foo.DiceRoller"
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:94)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:404)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:219)
org.apache.jasper.compiler.Validator$1MapperELVisitor.visit(Validator.java:1410)
org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:163)
org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:234)
org.apache.jasper.compiler.ELNode$Visitor.visit(ELNode.java:275)
org.apache.jasper.compiler.ELNode$Root.accept(ELNode.java:94)
org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:234)
org.apache.jasper.compiler.Validator$ValidateVisitor.getFunctionMapper(Validator.java:1420)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:637)
org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:913)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2230)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2236)
org.apache.jasper.compiler.Node$Root.accept(Node.java:485)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Validator.validate(Validator.java:1515)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:247)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:456)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


Peter Du
SCJP 1.4
Nov 26, 2004
I passed SCJP 1.4 today (91%). Thanks for this great site.
20 years ago
Thanks for your reply.
I understand better now. new MyClass() is translated to a call to the constructor at compile time. At runtime the constructor run first to create an instance of the MyClass, then the instance method MyMethod() is called.

Thanks again.

Peter Du
The following code when compile is OK, but from the point of operator precedence view, it seems it should not be OK, because operator new has lower precedence than operator . :
new MyClass().myMethod();
Thanks in advance.