Hello,

>From a servlet deployed in tomcat I am getting the
request parameter map by calling getParameterMap()
then using reflection calling a Class say "Sub" that
has a method "construct(HashMap requestMap)".  The
method is called properly but surprisingly I am
getting InvocationTargetException->ClassCastException
when I try to read the parameter from the map. 
Following is the code.

======== Code in Class called from Servlet ====
// Note that the map instance is an instance of
org.apache.catalina.util.ParameterMap
Method method   = cls.getMethod("constructSql", new
Class[]{request.getParameterMap().getClass().getSuperclass()});

query   = (String) method.invoke(obj, new
Object[]{request.getParameterMap()});

======== Code from Sub ============
public String construct(HashMap requestMap)     {
log.info("~construct()");
log.info("10");
Object obj      = requestMap.get("ParamKey");
log.info(obj.getClass());
log.info("10.1");
String str      = (String) obj;
log.info(str);
log.info("10.2");

return "";
}

======== Console Output ==========
INFO  [http-8080-Processor25] SearchCodeQuery     -
~construct()
INFO  [http-8080-Processor25] SearchCodeQuery     - 10
INFO  [http-8080-Processor25] SearchCodeQuery     -
class [Ljava.lang.String;
INFO  [http-8080-Processor25] SearchCodeQuery     -
10.1
INFO  [http-8080-Processor25] ServletRequestProcessor 
   - java.lang.reflect.InvocationTargetException
INFO  [http-8080-Processor25] ServletRequestProcessor 
   - java.lang.ClassCastException: [Ljava.lang.String;

Is it because that the instance is actually
org.apache.catalina.util.ParameterMap and I am trying
to call get() over that instance ?  But ParameterMap
itself does not have any implementation of get() it
takes that from its superclass i.e. HashMap.

Is it not supposed to run.  When you can see in the
log that the value is a String object and a similar
java application using LinkedHashMap and HashMap runs
without any hiccups ?

I am using JDK:1.5.0_03, Tomcat:5.5.9


Thanks in advance


Nitin



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to