W3C home > Mailing lists > Public > www-jigsaw@w3.org > March to April 1998

Re: Servlet Problems!

From: Benoit Mahe <Benoit.Mahe@sophia.inria.fr>
Date: Wed, 15 Apr 1998 14:16:45 +0200
Message-Id: <199804151216.OAA25014@www43.inria.fr>
To: "Wolfgang Platzer" <wplatzer@iaik.tu-graz.ac.at>
cc: "Jigsaw Mailinglist" <www-jigsaw@w3.org>
wplatzer@iaik.tu-graz.ac.at writes:

> I modified Jigsaw to set additional parameters for a request:
> import test.TestClass;
>   TestClass t = new TestClass();
>   request.setState("test.test_class", t);
> and then I wrote a servlet:
>      TestClass tc = (TestClass)req.getAttribute("test.test_class");
> But this line always causes a ClassCastException. If I write
>     Object o = req.getAttribute("test.test_class");
>     System.out.println(o.getClass().getName());
> I get
>     test.TestClass.
> It seems that Servlets use another ClassLoader than Jigasaw. Is this a
> general Problem with Servlets or is this problem specific to Jigsaw?
> If I use java.lang.String instead of test.TestClass there is no
> ClassCastException. Why?
> Can someone explain this?

 I see. Yes Servlets are loaded with a specific ClassLoader (LocalServletLoader)
 that allows auto reload when the servlet class is modified. But the 
 ClassLoader used for system classes is the default classloader, that's the 
 reason why there is no ClassCastException for String. 

 We haven't thought about that, so we have to find a solution. May be we could
 use the LocalClassLoader only for the servlet class (and not for embedded 
 classes) but this could create other problems, I have to think about that.


- Benoît Mahé -------------------------------------------------------
                      World Wide Web Consortium (W3C)
                    Architecture domain - Jigsaw Team           

  http://www.w3.org/People/Mahe - bmahe@w3.org - + 
Received on Wednesday, 15 April 1998 08:16:51 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:41:24 UTC