This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes doFilter method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "doFilter method" Watch "doFilter method" New topic
Author

doFilter method

amarkirt saroay
Ranch Hand

Joined: Mar 16, 2008
Posts: 167
HOw can we say that doFilter method is both a callback and an inline method?


SCJP-75%
SCWCD-82%
Tripati Sahu
Greenhorn

Joined: Jul 11, 2009
Posts: 25
A callback method, in the context of Web applications, is a method invoked by the container rather than by your own code. For example, you never invoke a servlet's service method yourself, instead the container does that for you when a client makes a request. In general, you'll write the callback method's implementation but never invoke it.

I imagine what's meant here by an "inline method" is one which you invoke directly in your own application's code: this may or may not be a method you have implemented yourself. For example, getServletConfig() is an "inline method" (I imagine). I may have that incorrect as I find it somewhat confusing terminology (for example, an invocation of an inline method in C++ is replaced by the expanded form of the method on compilation, a "feature" which doesn't exist in Java).


But the doFilter method can be called by ourself by writting chain.doFilter() as well as the container.
amarkirt saroay
Ranch Hand

Joined: Mar 16, 2008
Posts: 167
Is it like?

Filter.doFilter() is a callback wheras Filterchain.doFilter() is inline method?
Tripati Sahu
Greenhorn

Joined: Jul 11, 2009
Posts: 25
Suppose we have a chain of filter. the first filters doFilter method will be called by contained and the inside the doFilter method of the first filet we can call another Filters doFilter method by calling filterChain.doFilter. The first one is call back and the second one is inline. Hope it clarifies.
 
Don't get me started about those stupid light bulbs.
 
subject: doFilter method