Solved

Problem with Javascript Containing a Relative Path--I need an Absolute Path

Posted on 2010-11-15
5
332 Views
Last Modified: 2012-05-10
Dear Experts,

I have a challenge that I’m not sure I’ll be able to solve, but I thought if it was possible, someone here would know.  Here’s my issue:

I purchased a really nice script that slices HTTP uploads into smaller manageable pieces. I use it for clients who need to share large files, but find FTP too cumbersome, and it also makes large file uploads possible on a shared server. This is the product:  http://upload.thinfile.com/resume/

It works great, but only in a relative path environment.  I now have a couple of Wordpress sites that I’d like to incorporate this script on (in conjunction with a password protected page) but as you can guess, since I don’t have full path names for pages the script doesn’t work. I really don’t want to force Wordpress to show the full path name for each link, so that isn’t an option (and I'm not sure that would work anyways).

I sent an email to the company and they’ve ignored me, which is why I thought I would reach out to EE.

The script is essentially made up of 5 files:

applet.php
slice.php
ThinSlice.jar
thinupload.properties
embed.js

I imagine the settings that control the relative path are in the .jar file, but I have no experience with this type of file. I unzipped all the files to tried and take a look, but there are 38 .class files and they look to be encrypted.

I guess my long-winded question is, does it sound like this is anything that I can control/change, or does it seem more like these settings are set in stone and I’m out of luck?

I originally thought the issue was with the applet or embed.js file which I’ve pasted below. But even when I change the relative paths to absolute paths it still doesn't work, which is why I’m guessing the REAL issue is in the .jar file.

---------------------------

I set up a testing site here:

Page with Absolute Path that works right:
http://www.dzinentertainment.com/wp-content/themes/default/client-manager.php

Identical page in Wordpress that doesn't work right:
http://dzinentertainment.com/client-manager/

Here is a zipped folder with the 7 files that it takes to work:

http://dzinentertainment.com/sliced-upload.zip

I used these identical files for both pages above.

While I was setting up this test, I did copy the error message that comes up on the Wordpress page (you can see it there). I've pasted it below.

I hope this gives more helpful information.

----------------------Error Message I Get-----------------------------
      

Java Plug-in 1.6.0_20
Using JRE version 1.6.0_20-b02 Java HotSpot(TM) Client VM
User home directory = C:\Users\User
----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------


--- Init applet: com.screencastomatic.detect.DetectApplet[panel0,0,0,0x0,invalid,hidden,layout=java.awt.FlowLayout]
--- Start applet: com.screencastomatic.detect.DetectApplet[panel0,0,0,0x0,layout=java.awt.FlowLayout]
--- Init applet: com.screencastomatic.detect.DetectApplet[panel1,0,0,0x0,invalid,hidden,layout=java.awt.FlowLayout]
--- Start applet: com.screencastomatic.detect.DetectApplet[panel1,0,0,0x0,layout=java.awt.FlowLayout]
--- Init applet: com.screencastomatic.detect.DetectApplet[panel2,0,0,0x0,invalid,hidden,layout=java.awt.FlowLayout]
--- Start applet: com.screencastomatic.detect.DetectApplet[panel2,0,0,0x0,layout=java.awt.FlowLayout]
--- Init applet: com.screencastomatic.detect.DetectApplet[panel3,0,0,0x0,invalid,hidden,layout=java.awt.FlowLayout]
--- Start applet: com.screencastomatic.detect.DetectApplet[panel3,0,0,0x0,layout=java.awt.FlowLayout]
--- Init applet: com.screencastomatic.detect.DetectApplet[panel4,0,0,0x0,invalid,hidden,layout=java.awt.FlowLayout]
--- Start applet: com.screencastomatic.detect.DetectApplet[panel4,0,0,0x0,layout=java.awt.FlowLayout]
Thin Slice Upload. Demo Version 1.00.3
Thin File (Pvt) Ltd.
http://www.thinfile.com/
java.lang.NullPointerException
      at j.init(Unknown Source)
      at com.thinfile.upload.ThinSliceDemo.init(Unknown Source)
      at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
Exception: java.lang.NullPointerException
load: class com.thinfile.upload.ThinSliceDemo not found.
java.lang.ClassNotFoundException: com.thinfile.upload.ThinSliceDemo
      at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
      at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
      at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: C:\Users\User\Downloads\ThinSliceDemo\ThinSliceDemo-1.05\thin-slice-demo\thin-slice-demo\com\thinfile\upload\ThinSliceDemo.class (The system cannot find the path specified)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.<init>(Unknown Source)
      at java.io.FileInputStream.<init>(Unknown Source)
      at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
      at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
      at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
      at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
      at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      ... 7 more
Exception: java.lang.ClassNotFoundException: com.thinfile.upload.ThinSliceDemo
--- Init applet: com.screencastomatic.detect.DetectApplet[panel5,0,0,0x0,invalid,hidden,layout=java.awt.FlowLayout]
--- Start applet: com.screencastomatic.detect.DetectApplet[panel5,0,0,0x0,layout=java.awt.FlowLayout]
load: class com.thinfile.upload.ThinSlice not found.
java.lang.ClassNotFoundException: com.thinfile.upload.ThinSlice
      at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
      at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
      at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://dzinentertainment.com/client-manager/com/thinfile/upload/ThinSlice.class
      at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
      at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
      at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      ... 7 more
Exception: java.lang.ClassNotFoundException: com.thinfile.upload.ThinSlice

             
<------------------ Original applet.php -------------------->
   <?php	
		$useApplet=0;
		
		$user_agent =$_SERVER['HTTP_USER_AGENT'];

	   
		if(stristr($user_agent,"konqueror") || stristr($user_agent,"macintosh") || stristr($user_agent,"opera"))
		{ 		
			$useApplet=1;
			echo '<applet name="Thin Slice Upload"
					archive="ThinSlice.jar"
					code="com.thinfile.upload.ThinSlice"
					width="300" MAYSCRIPT="yes"
					height="309">';
			
		}
		else
		{			   
			if(strstr($user_agent,"MSIE")) { 
                echo '<script language="javascript" src="embed.js" type="text/javascript"></script>';				
			} else {
				echo '<object type="application/x-java-applet;version=1.4.1"
					width= "300" height= "309"  id="rup" name="rup">';
                echo '  <param name="archive" value="ThinSlice.jar">
                    <param name="code" value="com.thinfile.upload.ThinSlice">
                    <param name="MAYSCRIPT" value="yes">
                    <param name="name" value="Thin Slice Upload">';
			} 
		}

		if(isset($_SERVER['PHP_AUTH_USER']))
		{
			printf('<param name="chap" value="%s">',
				base64_encode($_SERVER['PHP_AUTH_USER'].":".$_SERVER['PHP_AUTH_PW']));
		}
		
		if($useApplet == 1)
		{
			echo '</applet>';
		}
		else
		{
			echo '</object>';
		}
?>  
<------------------ Absolute Path that I tried to change to fix the problem applet.php-------------------->


<?php	
		$useApplet=0;
		
		$user_agent =$_SERVER['HTTP_USER_AGENT'];

	   
		if(stristr($user_agent,"konqueror") || stristr($user_agent,"macintosh") || stristr($user_agent,"opera"))
		{ 		
			$useApplet=1;
			echo '<applet name="Thin Slice Upload"
					archive="http://domain.com/wp-content/themes/themename/ThinSlice.jar"
					code="com.thinfile.upload.ThinSlice"
					width="300" MAYSCRIPT="yes"
					height="309">';
			
		}
		else
		{			   
			if(strstr($user_agent,"MSIE")) { 
                echo '<script language="javascript" src="http://domain.com/wp-content/themes/themename/embed.js" type="text/javascript"></script>';				
			} else {
				echo '<object type="application/x-java-applet;version=1.4.1"
					width= "300" height= "309"  id="rup" name="rup">';
                echo '  <param name="archive" value="http://domain.com/wp-content/themes/themename/ThinSlice.jar">
                    <param name="code" value="com.thinfile.upload.ThinSlice">
                    <param name="MAYSCRIPT" value="yes">
                    <param name="name" value="Thin Slice Upload">';
			} 
		}

		if(isset($_SERVER['PHP_AUTH_USER']))
		{
			printf('<param name="chap" value="%s">',
				base64_encode($_SERVER['PHP_AUTH_USER'].":".$_SERVER['PHP_AUTH_PW']));
		}
		
		if($useApplet == 1)
		{
			echo '</applet>';
		}
		else
		{
			echo '</object>';
		}
?>

<------------------ Original embed.js-------------------->

document.writeln('<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"');
document.writeln('width= "300" height= "309"');
document.writeln('codebase="http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#version=1,4,1">');
document.writeln('<param name="archive" value="ThinSlice.jar">');
document.writeln('<param name="code" value="com.thinfile.upload.ThinSlice">');
document.writeln('<param name="name" value="Thin Slice Upload">');

<------------------ Absolute Path that I tried to change to fix the problem embed.js-------------------->

document.writeln('<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"');
document.writeln('width= "300" height= "309"');
document.writeln('codebase="http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#version=1,4,1">');
document.writeln('<param name="archive" value="http://domain.com/wp-content/themes/themename/ThinSlice.jar">');
document.writeln('<param name="code" value="com.thinfile.upload.ThinSlice">');
document.writeln('<param name="name" value="Thin Slice Upload">');

Open in new window

0
Comment
Question by:azlumiere
  • 3
  • 2
5 Comments
 
LVL 20

Expert Comment

by:Proculopsis
ID: 34136996

Just a random thought but could an html base tag help

<BASE HREF="http://www.dzinentertainment.com/wp-content/themes/default/client-manager.php"

Open in new window

0
 

Author Comment

by:azlumiere
ID: 34137337
Hi Preculopsis,

Thanks very much for your suggestion. I set this up in the header:

<BASE HREF="http://www.dzinentertainment.com/wp-content/themes/default/" />

But the applet still doesn't load here:

http://dzinentertainment.com/client-manager/

It still shows this in the error:

 failed:http://dzinentertainment.com/client-manager/com/thinfile/upload/ThinSlice.class
0
 
LVL 20

Accepted Solution

by:
Proculopsis earned 250 total points
ID: 34143734

Another idea might be to pop the sensitive html in an iframe, using your absolute path - not very nice but could work.
0
 

Author Comment

by:azlumiere
ID: 34145091
Oh, that's an interesting idea. I'll look into that....
0
 

Author Closing Comment

by:azlumiere
ID: 34362006
Preculopsis,
Sorry it took me so long to award points. It took me a month to test your theory about iframes, but it worked PERFECTLY. Thank you SO much for your help. Thank you for a simple, but effective answer to this question that has been haunting me for months!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question