File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Chapter 13 - Question 1

 
Srinivasan Rengan
Ranch Hand
Posts: 122
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Srinivasan Rengan
Ranch Hand
Posts: 122
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 445
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 122
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic