You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Andrew Bubnic <an...@channelmarketing.com.au> on 2006/05/02 03:58:12 UTC

Applet sharing utility class with Servlet

Hi guys, hoping someone has an answer to this:

 

I have a servlet and an applet running in the same webapp. The servlet
needs to access a class the applet .jar contains. The applet is visible
to the browser.

 

Problem is: I need to access this applet utility class (or it could be
any class really, outside the WEB-INF folder but inside the current
webapp) from the servlet. I don't want to actually access the running
applet on the user's end, just the .class on the server webapp (so I can
instantiate it etc). I also don't want to have to keep a copy of this
utility class with the servlet class as a work-around as it's rather
inelegant.

 

I have heard you can modify web.xml in the webapp\WEB-INF folder to
allow access to any .class/.jar in the current webapp but I haven't been
able to find how to do this.

 

If you have any ideas or leads about this problem, please let us know.
Thanks guys.

 

 


Re: Applet sharing utility class with Servlet

Posted by Jess Holle <je...@ptc.com>.
This is a "feature" of the servlet spec.

To use a class from both client and server you're forced to have 
multiple copies of it in your web app -- or alternatively to do 
non-standard adjustments to the web app loader / classpath.

If you don't have too many of these copy cases, I advise just having 
your build process produce the necessary copies.

Unfortunately, some of us have *lots* of these cases.  The lack of a 
"common" area which is accessible to client and server classloaders is a 
very unfortunate gap in the servlet spec in this case.

Andrew Bubnic wrote:
> Hi guys, hoping someone has an answer to this:
>
> I have a servlet and an applet running in the same webapp. The servlet
> needs to access a class the applet .jar contains. The applet is visible
> to the browser.
>
> Problem is: I need to access this applet utility class (or it could be
> any class really, outside the WEB-INF folder but inside the current
> webapp) from the servlet. I don't want to actually access the running
> applet on the user's end, just the .class on the server webapp (so I can
> instantiate it etc). I also don't want to have to keep a copy of this
> utility class with the servlet class as a work-around as it's rather
> inelegant.
>
> I have heard you can modify web.xml in the webapp\WEB-INF folder to
> allow access to any .class/.jar in the current webapp but I haven't been
> able to find how to do this.
>
> If you have any ideas or leads about this problem, please let us know.
> Thanks guys.
>   

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