Re: Servlet Problems!

In my servlet now I use a workaround:

String tcs = (String)req.getAttribute("test.test_class");
TestClass tc = new TestClass(tcs);


The reloading of a changed servlet works great!!!

I suggest only to reload the classes in the servlets directory and NOT to
reload classes which are defined in Jigsaw's classpath.

Wolfgang


-----Ursprüngliche Nachricht-----
Von: Benoit Mahe <Benoit.Mahe@sophia.inria.fr>
An: Wolfgang Platzer <wplatzer@iaik.tu-graz.ac.at>
Cc: Jigsaw Mailinglist <www-jigsaw@w3.org>
Datum: Mittwoch, 15. April 1998 14:18
Betreff: Re: Servlet Problems!


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.

Benoit.

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

  http://www.w3.org/People/Mahe - bmahe@w3.org - +33.4.92.38.79.89
---------------------------------------------------------------------

Received on Wednesday, 15 April 1998 08:24:22 UTC