July 15th, 2003, 04:14 AM
Using a JAR of JScript files with JSP
Any one knows if it is possible to use a JAR file that contain some ".js" files to be called from a JSP file.
I am running WebSphere 4.0.3 on WinXP
July 15th, 2003, 04:56 AM
I've tried to ask HTML guys, but no one helped, and most of them recomended posting in a Java Forum, so here I am......
Well it did worked on HTML files.....try this:
Create 2 .js files, each with different functions inside them, say:
save this as "test1.js", then.....
save this as "test2.js"
now take the 2 files and zip them into this file name "jscripts.jar"
Create an HTML file and add into it:
<input type="Button" value="Test JAR" onclick="test1();test2()">
You will find that the Button will call the 2 functions from the JAR file....kool, right?
The problem is that this method won't work when run on a Server, I tried many paths for the JAR file but it didn't work
If any one found a way, Please Mail Me.......
July 15th, 2003, 10:01 AM
I am using Websphere 4 as well.
What is the relative web path from the page with the button to the jar file?
if the pages url is...
and the jar is located at...
then the src attribute path should be...
I'm not sure if the './' is neccassary, but I always use it and Websphere seems not to mind.
July 15th, 2003, 10:16 AM
I think it is neccesary. At least the "/". Usually i try different variations "./","/" etc, until Webshere understands what I'm trying to tell it.
shouldn't your *.jar files be located somewhere in the WEB-INF directory ?
Now is the winter of our discontent made glorious summer by this son of York.
July 15th, 2003, 10:26 AM
I usually leave my js files in a js directory at the root of the web app unzipped, not sure why some one would want to do zip them together. I hate when people ask me "Why are you trying to do that?" so I figured he had his reasons.
Sherif, the other thing I thought of was that it may be the mime types that are screwing you up. The server might not like sending jar files as an archive to the web browser. You might want to try a zip file instead.
July 16th, 2003, 03:39 AM
Ok, thanx guys but the suggestions did not work with me; can I explain in detail what I do........
The JAR & HTML Files are located on my HDD at :
I call it (locally) from the browser like this:
I've attached the files (1kb Zip) for anyone to try it out....
If you just call the test.htm file from the Browser, it will work, but from the Server, it won't.
Sm00ve, I do have my reasons, the client I am writting code for, is in some place where ppl use dial-up with 3kb/sec MAX, and I got 100kb pages with 25kb JScript files, thus compressing them into a 5kb JAR file will help a lot....
Guys, if any one can get it to work it will really help......all of us (or most of us, I guess)......
July 16th, 2003, 07:40 AM
I found the following info segiment here...
I use this site for javascirpt reference and have found it somewhat useful.
I'm sorry but it doesn't look like you will be able to have this work on IE.
However, I was curious do your pages need ALL of the functions that are in each page or just some of them?
One thing I do with my .js files is to break up each page into a logical grouping (i.e. I have 1 js that has the most common functions, and then I have a js file that is specific to a particular page that contains functions only used for that page). This way I am only ever includeing 2 or three SMALL js files at a time.
Just a thought.
Last edited by Sm00ve; July 16th, 2003 at 07:49 AM.