Announcement: Be excellent to each other.


Caravel Forum : Other Boards : Anything : javascript help
New Topic New Poll Post Reply
Poster Message
bradwall
Level: Smiter
Avatar
Rank Points: 423
Registered: 02-12-2003
IP: Logged
icon javascript help (0)  
I can't seem to figure out how to save a file from the server onto the client using java script.
In my .jsp file, I need to write a function that will take a .ico file from the server and then copy that .ico to the client machine.
Does anyone have any thoughts on doing this? I can't seem to figure out how to do this.

04-22-2005 at 05:17 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
wmarkham
Level: Master Delver
Avatar
Rank Points: 125
Registered: 12-06-2004
IP: Logged
icon Re: javascript help (0)  
Well, I don't know if this is helpful or not, but as I understand it, the goal that you describe doesn't sound doable. IIUC, .jsp is server-side Javascript, used to generate a document to send to a client web browser through HTTP. Even ignoring security issues, I wouldn't expect HTTP to provide any mechanism to directly access the client's hard drive. Or are you trying to dynamically generate an .ico file that just gets sent back as the usual reply? (By the way, I've played a bit with Javascript, and not at all with .jsp, so naturally I might not know what I'm talking about!)
04-22-2005 at 07:08 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
bradwall
Level: Smiter
Avatar
Rank Points: 423
Registered: 02-12-2003
IP: Logged
icon Re: javascript help (0)  
Thanks for the reply.
Right now, this is what is going on...
We have a system that our company has programmed using J2EE. The server is a Linux server and the clients are all Windows. We have a section of the program that pulls up a .jsp file and has a function to create a shortcut:
function createShortCut()
{
// Build the address that will be the argument
var address = "http://" + document.location.hostname + ":" + <%=returnPort()%> + "/dms/proquestSecure.hta" +
"?cmd=start" +
"&username=" + document.all.username.value +
"&password=" + // document.all.j_password.value +
"&database=" + document.all.DatabaseDropDown.options[document.all.DatabaseDropDown.selectedIndex].innerHTML +
"&workstation=" + document.all.WorkstationDropDown.options[document.all.WorkstationDropDown.selectedIndex].innerHTML;

var wShell = new ActiveXObject("WScript.Shell");
var DesktopPath = wShell.SpecialFolders("Desktop");
var cut = wShell.CreateShortcut(DesktopPath + "\\\\" + document.all.shortcut.value + ".lnk");
cut.TargetPath = "mshta.exe";
cut.Arguments = address;
cut.Description = "ADP Dealer Management System";
cut.WindowStyle = 1;
cut.IconLocation = "%SystemRoot%\\\\explorer.exe, 10";
cut.Save();

window.close();
}

The problem is that I don't want to use:
cut.IconLocation = ".... explorer.exe...
I want to use an icon that is located on the Linux server.
I tried creating a fso object, but FileCopy will not work between Linux and Windows.

04-22-2005 at 07:24 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
wmarkham
Level: Master Delver
Avatar
Rank Points: 125
Registered: 12-06-2004
IP: Logged
icon Re: javascript help (0)  
Ah. Perhaps I understand. (perhaps)

The createShortCut code is actually running on the client machine. It just happens to be in a document that has been generated from a .jsp that ran on the server. Here's what I understand for you need to do:

Put the file that you want to copy in a location on the web server that can be accessed through HTTP. Then in the script, you just need to copy the file from its http://whatever location on the server. I don't know WMI stuff well enough (or, I guess WScript something different, right? that's about how well I know it, anyway) to know if it already provides a quick-n-easy way to do it, (like specifying a URL as the source location) but there certainly are ways to access HTTP from JavaScript. See http://jibbering.com/2002/4/httprequest.html for some low-level examples. Perhaps look at http://www.oreillynet.com/pub/a/javascript/synd/2002/08/30/mozillasoapapi.html which describes a SOAP API. (Although that's probably way too high-level.) Also, look at DHTML, which I've used to download documents within frames in the browser. There may be a simple way to insert the .ico into the browser's DOM, and then save it from there.

That's about all the help I can give.

04-24-2005 at 07:35 AM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
New Topic New Poll Post Reply
Caravel Forum : Other Boards : Anything : javascript help
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.