Skip to main content

Posts

Showing posts from March, 2013

my tailor uses Custom tag

Custom tags to avoid placing java code inside the JSP page "scripting", so that the JSP page is able to concentrate only on the presentation logic. old "classic" where a developer has to adjust the flow, from start go to ?? , will evaluate the body or not, all done depending on the return value of overridden methods . instance of tag handler is reused, can't rely on constructor to do initialization, better to use setPageContext( ). now everything is done overriding just one method. simple tag model never reuse tag handler instances. body content: in practice content is not processed at all JspWriter out=getJspContext().getOut(); out.print(" ... "); getJSPBody.invoke(null); out.print(" ... "); Modify to process body content StringWriter writer=new StringWriter(); getJSPBody.invoke( writer ); String bodyContent=writer.toString(); .tld addresses to custom tag, so how to know about explicit "within web.xml"

scattered

Blocks anonymous inner class is for overriding methods of super class. static blocks are called just once "say at class loading time". anonymous blocks are called every time a constructor is called but before it. static{ // block executed at class load time just once } { //anonymous block within class scope called before each instantiation call } Enumeration is an interface that provide an abstract mechanism for visiting elements. enum Meal{ BREAKFAST(7,30),LUNCH(1,30); private int h,m; Meal(int h, int m){ this.h=h;this.m=m}.... Polymorphism is that you declare, say, a method argument of a particular type and at run-time be able to have that argument refer to any sub-type.  void methodName( ArrayList <Animal>  list ){ list.add( new Dog() ) } what if i passed a cat list, i'll then end up having a dog in my cat list, so since at run-time JVM knows the type of arrays, but not the type of collection. < ? extends  > can't add to the