• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

access to helper classes under web-inf from applet?

 
Quinton Haselhorst
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Posted on this board almost two years ago
Originally posted by Frank Carver:
The difficulty with deploying applet code in WEB-INF/classes is that you should never make WEB-INF/classes visible to the webserver, otherwise potentially secret or damaging server-side code is available to all users.
If the shared applet classes are all grouped in a package , then you might consider making a link from a web-visible directory to the package directory, otherwise you will really have to maintain two copies of the shared class hierarchy - one copy safe in WEB-INF/classes, hidden from view with all the server-side code, and one copy somewhere visible for users to download as an Applet.

I have exactly the same problem; I�m developing an application that has it all; controller servlet, JSPs, applets...
Now one applet communnicates with a servlet by exchanging Activity classes amongst one and other. Obviously they both have to have the same version of Activity class, so I don�t think duplication of code is a good idea (it never is actually..)
So here�s the problem:
Servlets (+ helper Activity package) are in WEB-INF/classes
Applet is on the same level as my JSPs (it can�t be under WEB-INF cause then it wouldn�t be accessible to the client!), and it has its own copy of the Activity-package.
Now, does anybody in here have an idea what to do to eliminate the duplication of the Activity package? Or, how do I create the "link" suggested above?
Thanks a lot!
Rein
 
Tim Holloway
Saloon Keeper
Posts: 18367
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, put the shared classes in a JAR, if you haven't already done so.
There are several ways to keep the applet and server code in sync. On Windows 2000 and the Unix OS's (including Linux), you can make an alias (also known as a "link") so that you have the appearance of two copies of the file but actually only have one. So for example, WEB-INF/lib/utility.jar could be a link to the utility.jar that's seen by your applet (e.g. in the "/" directory of the webapp). Just for safety's sake, make this file readonly, BTW.
A variation on this for an even more generally usable set of utilities is to place the master copy in some completely isolated directory and inform the appserver that this is a server-global class library (the exact mechanism depends on the server you're using). In this case, you'd use a link in the webapp's "/" to that copy. This is actually slightly safer since a vandal not only has to be able to modify web pages (which means you're doomed anyway). but also to reach across the linking mechanism.
A variant of this is to put the applet utility jar or its link in a subdirectory of the webapp (but not WEB-INF) and alter the URL accordingly. Then you can set access rights on that subdirectory as well.
For Windows NT and 9x, you don't have a file alaising capability, so you just need to use some sort of install process that rpelicates copies as needed.
 
Quinton Haselhorst
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey thanks a lot for your reply!
I was hoping for a slightly more "elegant" solution, but yeah...
Because if I understand correctly, I have to make a different kind of linking mechanism for every other OS, and since I�m developing this web app for my thesis, I would have rather seen a more theoretical, cross-platform kind of solution.
But if that doesnt exist, then there�s nothing you can do about it right...
Thanks a lot Tim!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic