Link to home
Start Free TrialLog in
Avatar of ST3VO
ST3VOFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Servlet Needed Urgently

Hi expert,

Hope you can help me with this.

I need a Servlet that I can use to execute an application(exe) from a link via a web page.

Could someone help me with this please?

Thanks

ST3VO
 
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

How would you stop unauthorised users doing that?
Assuming you've addressed that properly, read this thoroughly:

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

You'll need to call Runtime.exec in doGet
here u go:

import java.io.*;
import javax.servlet.http.*;
import javax.servlet.*;

public class ExecServlet extends HttpServlet {
  public void doGet (HttpServletRequest req,
                     HttpServletResponse res)
    throws ServletException, IOException
  {
    Runtime.getRuntime().exec("whatever.exe");
  }
}
That's an excellent example of how *not* to do it. (Read the link i posted)
Avatar of ST3VO

ASKER

1 question objects, with the servlet be run from the browser and then the servlet executes my exe?

I've written an application with works with a 3D engine and I need to users to be able to run it from a link on the html page.

Due to security issues, this is not possible, so after some research I read that this was possible via a Java Servlet...so that's why i'm posting here :o)

I have no experience with java at all. Do I need to comile your code objects?  Could you point me to some tool to do this please?

Sorry about that...I know nothing about Java :o)

Thanks

ST3VO
> 1 question objects, with the servlet be run from the browser and then the servlet executes my exe?

yes, servlkets run server side

What exactly does the exe do, whats the output?

You may actually want to run it client side, in which case you could use some signed java code to execute it.
>>I read that this was possible via a Java Servlet...so that's why i'm posting here

It might be possible. What kind of output does your program have? If it has a GUI, you won't be able to do it without a lot of difficulty
Avatar of ST3VO

ASKER

We yes, it uses DirectX and Windows GUI :o/
then you'll need to run it client side which would require signed code.
Pretty straight forward, you just need a certificate.

Why are you using Java btw?
user could just download the exe directly and run it themselves.
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ST3VO

ASKER

Yes, but the prolem is that I need to do it via a web link and due to permission the browser will not let ths happen.
browser won't let you run it, but they can still download it. And include instructions on the page about how to run it once they have downloaded.
A Lot simpler than use signed code to download and execute it.
Avatar of ST3VO

ASKER

I've already got it working that way but I am required to do it via the brower :o/
Then you should provide the kind of interface i mentioned above
Avatar of ST3VO

ASKER

Thanks guys !!!
Then perhaps you should be going down the .NET route instead of Java
See if this is applicable

http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=187

To do it with Java you'd need to use signed code to download the exe, save it to the local disk and then execute it. Not the cleanest of solutions.
:-)
Avatar of ST3VO

ASKER

THanks again!!!

glad I could help :)