Found the problem. I ended up using a different approach to getting the
parent tags value by using the following line of code in place of the
complaining code.


     Method call = null;
     call = parent.getClass().getMethod("getDatabaseMetaData", new
Class[]{});
     databaseMetaData = (DatabaseMetaData) call.invoke(parent, null);

In addition to this there was a glaring error that may have permitted the
first snippet of code to work but I will never know. At the top of the class
I forgot to declare the package for the class and hence the access to the
parent class could not be resolved as it was in the package in question. Log
files are a wonderful thing.

----- Original Message -----
From: "Bryan LaPlante" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 24, 2003 10:28 AM
Subject: java.lang.reflect question


> Hi,
> I am having some trouble in the following situation. I have a parent child
> tag scenario where I am trying to get the value of parameter declared in
the
> parent tag and use it to do some work in the child tag.
>
> JRun4
> jdk 1.4.0
> WinXP pro
>
> The jsp syntax looks like so.
>     <sql:DatabaseMetaData datasource="dsn">
>         the database is found and an instance of DatabaseMetaData is
created
>         complete with a getter and setter before the child tag runs.
>
>         <sql:MetaTables tableNameSchema="types">
>             I need to use the same instance of DatabaseMetaData declared
in
> the
>             parent tag so I don't have to create another connection to the
> database.
>         </sql:MetaTables>
>     </sql:DatabaseMetaData>
> The line of code that is failing is
> databaseMetaData = (DatabaseMetaData)
>
parent.getClass().getField("databaseMetaData").get(java.sql.DatabaseMetaData
> );
>
> The error is "cannot resolve symbol class sql". The entire code snippet is
> below. Any insight will be appreciated.
>
>
>    Object parent = getParent();
>    if(parent != null){
>     try{
>      databaseMetaData = (DatabaseMetaData)
>
parent.getClass().getField("databaseMetaData").get(java.sql.DatabaseMetaData
> );
>     }
>     catch(NoSuchFieldException fe){
>      throw new JspException("An error occurred attempting to access the
> parent tags databaseMetaData field");
>     }
>     catch(SecurityException se){
>      throw new JspException("A security error occurred attempting to
access
> the parent tags databaseMetaData field");
>     }
>    }else{
>     throw new JspException("cant find the DatabaseMetaData tag");
>    }
>
> Bryan LaPlante
> http://www.netwebapps.com
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
>
> Some relevant archives, FAQs and Forums on JSPs can be found at:
>
>  http://java.sun.com/products/jsp
>  http://archives.java.sun.com/jsp-interest.html
>  http://forums.java.sun.com
>  http://www.jspinsider.com
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com

Reply via email to