You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kristian Rink <kr...@zimmer428.net> on 2007/10/09 11:30:11 UTC

[OT] applets in webapps

Folks,

slightly OT: can someone provide me with a few good pointers and/or
hints how to correctly integrate a Java applet into a JEE based web
application? 

More specifically, my problem is something like that: I do
have a .jsp containing code to show an applet. Both applet .class and
some other resources (.properties files, images, ...) do live inside
a .jar file in the same folder as the .jsp. Unfortunately(?), the .jsp
is never called directly but rather forward()ed to from within a
servlet mapped to some specific URL. So, the situation is that

- while calling the .jsp directly (using 

http://<host>/<context>/<real-path-to>/file.jsp ), the applet loads and
runs the way it's supposed to, but

- while having the resource called the way it's supposed to (using

http://<host>/<context>/<mapping-for-servlet-forwarding-to-jsp>/ )

the plugin doesn't load but provide me with ClassNotFoundException,
obviously not capable to find the applet class. Tried playing around
with the applets "archive" / "codebase" parameters made things just
slightly better: By now the browser does lock up, the applet class
seems to get loaded, but obviously fails to load some resources, and I
see strange access attempts in my tomcat log, trying to fetch resources
like

/<context>/<servlet-mapping>/<classpath>/lang/de_DE.properties  

(the file originally lives inside the applet.jar in <classpath>.lang).

Is there any sane way of keeping applets inside a JEE web application,
regardless on whether they're invoked directly from a .jsp or from a
resource forwarded to from within some servlet? Or am I just too stupid?

Sorry again for the OT, feel free to contact me off-list in case you
feel like providing me with some hints / pointers.

Thanks loads and best regards,
Kristian

-- 
Kristian Rink * http://zimmer428.net * http://flickr.com/photos/z428/
jab: kawazu@jabber.ccc.de * icq: 48874445 * fon: ++49 176 2447 2771
"One dreaming alone, it will be only a dream; many dreaming together
is the beginning of a new reality." (Hundertwasser)

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] applets in webapps

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kristian,

Kristian Rink wrote:
> Unfortunately(?), the .jsp
> is never called directly but rather forward()ed to from within a
> servlet mapped to some specific URL.

Are you trying to use relative URLs for your codebase? Try using a
fully-qualified URL (starting with a '/') to point to the JAR file
instead of a relative URL. Then, it doesn't matter where you include
your applet's JSP file, since the URL will always be fully-qualified.

> /<context>/<servlet-mapping>/<classpath>/lang/de_DE.properties  

That's weird. Shouldn't the applet's JAR file contain these properties
files? When you say "<context>" you mean the actual context name, not
'<' + "context" + '>', right?

> (the file originally lives inside the applet.jar in <classpath>.lang).

What is <classpath>.lang?

> Is there any sane way of keeping applets inside a JEE web application,
> regardless on whether they're invoked directly from a .jsp or from a
> resource forwarded to from within some servlet?

As long as you've got everything in your JAR file, you should be okay.
Or, are you trying to rely on the browser plugin's ClassLoader to fetch
things like properties files off the server?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHC4bq9CaO5/Lv0PARAhFJAKC9itbjJVgu9lagd0HJR2MU2NPQzgCfT7TW
PjBTxucwSIbxIJVPcEB7xh0=
=krGh
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] applets in webapps

Posted by Kristian Rink <kr...@zimmer428.net>.
David;

first off, thanks loads for your hints; much appreciated. :)

Am Tue, 09 Oct 2007 05:54:16 -0400
schrieb David Smith <dn...@cornell.edu>:

> Let's say the servlet serving up your applet and resources is mapped
> to /appletRes in your webapp.  The jsp could then access 
> ${request.contextPath}/appletRes/resources/applet.class or what
> ever. The client browser would then request the applet/resources
> separately and the companion servlet would find
> resources/applet.class in your jar file.

Thought about something like that already, as well. However I am unsure
whether it would work out, given that, in our case and looking at what
the applet does, we need to have it digitally signed and packed to
a .jar because of that. Won't using a servlet to provide these
resources from within the .jar file make this sort of providing a
signed applet impossible?

Cheers & best regards,
Kristian

-- 
Kristian Rink * http://zimmer428.net * http://flickr.com/photos/z428/
jab: kawazu@jabber.ccc.de * icq: 48874445 * fon: ++49 176 2447 2771
"One dreaming alone, it will be only a dream; many dreaming together
is the beginning of a new reality." (Hundertwasser)

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] applets in webapps

Posted by David Smith <dn...@cornell.edu>.
Keep in mind the applet is client side code and has to be available to 
the client.  To that end have you thought about a companion servlet that 
accepts requests and returns applets and other resources?  Then jsp code 
would just reference the mapped servlet in what it offers up to the client.

Let's say the servlet serving up your applet and resources is mapped to 
/appletRes in your webapp.  The jsp could then access 
${request.contextPath}/appletRes/resources/applet.class or what ever.  
The client browser would then request the applet/resources separately 
and the companion servlet would find resources/applet.class in your jar 
file.

The default servlet in tomcat could provide the base for your companion 
servlet -- just download the tomcat source and copy that code for your use.

--David

Kristian Rink wrote:
> Folks,
>
> slightly OT: can someone provide me with a few good pointers and/or
> hints how to correctly integrate a Java applet into a JEE based web
> application? 
>
> More specifically, my problem is something like that: I do
> have a .jsp containing code to show an applet. Both applet .class and
> some other resources (.properties files, images, ...) do live inside
> a .jar file in the same folder as the .jsp. Unfortunately(?), the .jsp
> is never called directly but rather forward()ed to from within a
> servlet mapped to some specific URL. So, the situation is that
>
> - while calling the .jsp directly (using 
>
> http://<host>/<context>/<real-path-to>/file.jsp ), the applet loads and
> runs the way it's supposed to, but
>
> - while having the resource called the way it's supposed to (using
>
> http://<host>/<context>/<mapping-for-servlet-forwarding-to-jsp>/ )
>
> the plugin doesn't load but provide me with ClassNotFoundException,
> obviously not capable to find the applet class. Tried playing around
> with the applets "archive" / "codebase" parameters made things just
> slightly better: By now the browser does lock up, the applet class
> seems to get loaded, but obviously fails to load some resources, and I
> see strange access attempts in my tomcat log, trying to fetch resources
> like
>
> /<context>/<servlet-mapping>/<classpath>/lang/de_DE.properties  
>
> (the file originally lives inside the applet.jar in <classpath>.lang).
>
> Is there any sane way of keeping applets inside a JEE web application,
> regardless on whether they're invoked directly from a .jsp or from a
> resource forwarded to from within some servlet? Or am I just too stupid?
>
> Sorry again for the OT, feel free to contact me off-list in case you
> feel like providing me with some hints / pointers.
>
> Thanks loads and best regards,
> Kristian
>
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org