PDA

View Full Version : How to call exe from jsp dynamically without hardcoding file path



kyawmyothet
04-16-2007, 07:57 AM
Hi all,
I face some problem, I want to run exe from JSP. I can run it but I need to give full path of file. I want to call dynamically without hardcoding fullpath. Just giving filename.

I don't want

exec ("C:\Program File\Coro\sign.exe");

I want

exec("sign.exe")

codeexploiter
04-17-2007, 12:54 PM
I don't know for sure but what about using the getRealPath method available in ServletContext interface.

Refer the docs from here (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String))

This method will give you the actual physical path of the executable file without hard coding the path in the source code.