aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Chapter 13 - Question 1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Chapter 13 - Question 1" Watch "Chapter 13 - Question 1" New topic
Author

Chapter 13 - Question 1

Srinivasan Rengan
Ranch Hand

Joined: Nov 07, 2004
Posts: 122
Hi Friends,
The answer for the first question is given as 'The destroy method is always a container callback method.'
It is also stated that doFilter is both a callback and an inline method.

My question is, what is inline method and what is callback method?

Thanx in advance,

Srini


SCJP, SCWCD, SCBCD (EJB 2.x and EJB 3), OCA, SCDJWS
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
Hi Srinivas,

Find my understanding on this.

Callback method is one, which container calls as part of life cycle.

Inline method is one which you can call in the code to perform some action.

doFilter() method is defined as part of life cycle of Filter. Also in doFilter() method you call chain.doFilter() to continue chaining.

But destroy() is only callback method. Even though you call destroy() method servlet may not get unloaded.

It is not a rule that if we call callback method there will not be effect at all. Though doGet() is a callback method, still we can call that as inline method also in code. No one stops calling that.


Rizwan
SCJA, SCJP, SCWCD, SCBCD, SCDJWS.
Srinivasan Rengan
Ranch Hand

Joined: Nov 07, 2004
Posts: 122
Hey Rizwan,
Thanks a lot. I think what you say is correct. Rizwan, I am not able to get an answer to another question, which I have even posted in this forum.

Assume the following:

<my:Function color="red">
<my:Function color="green">
<my:Function color="blue"/>
</my:Function>

</my:Function>


If my jsp file is calling SimpleTag in this way. Now, the moment it gets on to the 3rd tag, which is not having the body, the setJspBody method will not be called. Hence, JspBody will be null. So, if we have to print the value, we will not be able to use the JspWriter, because JspWriter is got from the JspBody object. Thus, how should my java file which extends SimpleTag be. I am confused.

Srini
->
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
Srini, Still I have to read more on Tag handlers. I can answer your question when I get to that point. But why do u want to take jspwriter object from jspBody. Cannot you take form jspcontext which is available for any tag class?
as getJspContext().getOut().write(attrValue);
Srinivasan Rengan
Ranch Hand

Joined: Nov 07, 2004
Posts: 122
Hi Rizwan,
Sorry I was wrong during my previous post. I did not mean getJspBody().getOut(), but instead I meant getJspBody().invoke(null). In this case, it turns out to be null, thus when we try to do it, it gives a big NullPointer exception.

Srini
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Chapter 13 - Question 1
 
Similar Threads
HFSJ Coffee Cram Chapter 13 Filter
Question about callback and inline method
Container Callback method doubt
Container callback and inline methods
callback and inline methods