• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Chapter 13 - Question 1

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic