Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with running a batch file on click in a JSP application

Status
Not open for further replies.

Khold

MIS
Jun 22, 2008
25
GB
Hi all,

I have the following code in my JSP app:

<a href="runApp('file://capScrAndSend.bat');" class="mainbars"> CONTACT ADMIN </a>

The batch file is present in the root directory of the web application. It does two things:
1.) runs a java class which is present in a sub-directory of the web application
2.) calls upon a vbscript which is also in a sub-directory of the web application

The Javascript code for the function runApp(), present in the <head> tag of the HTML in the JSP page is the following:

<script type="text/javascript">
function runApp(which) {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run (which,1,false);
}
</script>


The page is in the same directory as the batch file i.e. the root directory of the web application.

I have tried running the batch file by passing a lot of kinds parameters to runApp(), including its absolute path, but I get the usual "requested resource not available" HTTP Status 404 error (represented below):

type Status report

message /GSDC5Pv3/runApp('file://capScrAndSend.bat');

description The requested resource (/GSDC5Pv3/runApp('file://capScrAndSend.bat');) is not available.


I would be really grateful if someone could help me run a batch file of this kind (with a relative path to the web application) in any possible form, as I really need this functionality to be implemented.

Thanks in advance. Please do reach me if any more information is needed.



 
Hey,

I don't want to configure anything manually on the client side. Is there a way to modify the user's policy environment programmatically?

I was able to write a file to the client's system (a new one), but the same method is not working apparently for reading files from the client's file system.

 
I don't think you can do that due to security reasons. Again, change the java.policy and check it's a permissions issue.

Cheers,
Dian
 
I managed work around this as well by rearranging my applet code a little bit.

I now face a minor issue, but it is going to affect user friendliness, so I want to get to solving it.

When I fire up the java applet's method to throw the file save dialog, it does it's job. But the dialog box is often not in focus (i.e. the user cannot do anything with it). A majority of the time, you will have to alt-tab a little and then choose the file dialog to make it usable.

How do I avoid this and make the dialog come onto focus immediately after it is thrown? I am currently using the java swing API's JFileChooser to throw the dialog. My applet does not paint a GUI as this is the only component required.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top