J
Jim Cochrane
(I'm using Tomcat on Linux, in case it matters.)
I have a JSP application that uses an applet and a servlet for which
several library files are used by both the servlet and the applet.
Instead of duplicating the shared files - e.g., in different jar files
within the webapps directory, I'd like to allow the servlet and applet to
use the same jar file for the shared classes.
I've found a solution that works, but that does not seem particularly
elegant (as well as not being portable to Windows): In the app.jsp file
that loads the applet:
<applet codebase="classes" archive="applib.jar" code="Main_Applet.class"
... >
Since the servlet expects the applib.jar file to reside under WEB-INF, I
have hard-linked the file such that it occurs twice within the web
application directory:
../WEB-INF/lib/applib.jar
../classes/applib.jar
I first tried a symbolic link and the applet failed to load, undoubtedly
because of the security mechanism.
This solution essentially provides what I want - allowing the servlet and
applet to share the same file rather than accessing two different copies of
the same file (saving disk space and guarding against accidentally using
different versions of applib.jar), but, as I said, it's not very elegant.
I originally tried loading the applib.jar file from its original location:
<applet codebase="WEB-INF/lib" archive="applib.jar" code="Main_Applet.class"
... >
but the applet failed to load - because of the security mechanism, I
assume.
So my question is: Is it possible to come up with a portable solution that
allows the servlet and applet to use the same file in the same location
(i.e., with only one link), where portable means it will work on Linux,
Windows, and UNIX platforms?
A further question: Is it possible to come up with an even cleaner
solution, something like e.g., the applet-specific class files are stored
in applet.jar and the applet loads classes from both applet.jar and from
applib.jar (so that applib.jar does not need to contain applet-specific
class files, irrelevant for the servlet), where applib.jar is again shared
by the servlet and the applet?
[I did some googling and looking through applet and JSP docs to try to find
an answer, but with no luck, except for the above inelegant solution. The
solution is probably out there, if there is one, I just didn't find it.]
(I'm posting this question here because it appears to be the most relevant
java group for this topic. It's odd, though that there is no java
newsgroup specific to web development (unless I missed it?).
[comp.lang.java.programmer seems to cover a lot of very disparate topics -
I suspect I'm not the only one who finds this a little irritating and
inefficient.])
Thanks very much!
I have a JSP application that uses an applet and a servlet for which
several library files are used by both the servlet and the applet.
Instead of duplicating the shared files - e.g., in different jar files
within the webapps directory, I'd like to allow the servlet and applet to
use the same jar file for the shared classes.
I've found a solution that works, but that does not seem particularly
elegant (as well as not being portable to Windows): In the app.jsp file
that loads the applet:
<applet codebase="classes" archive="applib.jar" code="Main_Applet.class"
... >
Since the servlet expects the applib.jar file to reside under WEB-INF, I
have hard-linked the file such that it occurs twice within the web
application directory:
../WEB-INF/lib/applib.jar
../classes/applib.jar
I first tried a symbolic link and the applet failed to load, undoubtedly
because of the security mechanism.
This solution essentially provides what I want - allowing the servlet and
applet to share the same file rather than accessing two different copies of
the same file (saving disk space and guarding against accidentally using
different versions of applib.jar), but, as I said, it's not very elegant.
I originally tried loading the applib.jar file from its original location:
<applet codebase="WEB-INF/lib" archive="applib.jar" code="Main_Applet.class"
... >
but the applet failed to load - because of the security mechanism, I
assume.
So my question is: Is it possible to come up with a portable solution that
allows the servlet and applet to use the same file in the same location
(i.e., with only one link), where portable means it will work on Linux,
Windows, and UNIX platforms?
A further question: Is it possible to come up with an even cleaner
solution, something like e.g., the applet-specific class files are stored
in applet.jar and the applet loads classes from both applet.jar and from
applib.jar (so that applib.jar does not need to contain applet-specific
class files, irrelevant for the servlet), where applib.jar is again shared
by the servlet and the applet?
[I did some googling and looking through applet and JSP docs to try to find
an answer, but with no luck, except for the above inelegant solution. The
solution is probably out there, if there is one, I just didn't find it.]
(I'm posting this question here because it appears to be the most relevant
java group for this topic. It's odd, though that there is no java
newsgroup specific to web development (unless I missed it?).
[comp.lang.java.programmer seems to cover a lot of very disparate topics -
I suspect I'm not the only one who finds this a little irritating and
inefficient.])
Thanks very much!