JavaServer Page

January 31, 2007

Java reflection Once we have a Class object

Filed under: JSP Tag Libraries — webmaster @ 8:16 pm

CHAPTER 8 Using JavaBeans with tags All parameters and return codes in invoke() are passed wrapped within an object type. If some of the parameters or the return value are of primitive types (such as char) they need to be wrapped in an object (such as java.lang.Character). Table 8.3 presents the primitive types and their corresponding wrapping objects. The object on which invoke() will execute the method is passed as the obj parameter to invoke(). Since the number of parameters differs from one method to another, invoke() accepts an array of objects in which we place the parameters according to the order of declaration. The value returned from the invoked method is returned from invoke() (wrapped in an object if necessary). Exceptions thrown by the invoked methods are thrown by invoke() wrapped inside a java.lang.reflect.InvocationTargetException (from which you can then obtain the original exception). All methods that return type information, for example getParameter- Types(), return Class objects that represent this type. Even void has a Class object of type java.lang.Void to represent it. Table 8.3 The primitive types and their corresponding wrappers Primitive type Wrapper class boolean java.lang.Boolean char java.lang.Character byte java.lang.Byte short java.lang.Short int java.lang.Integer long java.lang.Long float java.lang.Float double java.lang.Double The Method class provides the functionality we need to call any method with whatever arguments are necessary for a given class. This class will be very useful as we build our JavaBean tags.

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by Java Web Hosting