Batch file and JSP

how can i call a batch file from JSP ??? possible ?

'tis possible, but not recommended.
You can use java.lang.Runtime.exec() method
Read all about it here: http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
Note that this will run a batch file on the server - not on the client machine.

Similar Messages

  • How to execute java batch file in JSP

    Kindly give a solution. I want execute a batch file which gives a preview window ,. I want call that batch file in my jsp, .I am using Tomcat 5.5, I have tried that using a Process object and Runtime.getRuntime().exec(path) , where path is location of my batch file. As a java class i could execute the batch file, but when i import the method in JSP nothing is happening (even no jsp error).
    Is it possible to execute the batch file in JSP?
    Can any one help me?

    itsdhanasaraa wrote:
    But as this a web application ... By using Runtime i'm getting some probs ..
    Let me guess, you want your web application to run a program on the client and to your surprise that's not working?
    Ain't gonna happen.
    its taking more time to execute .... that's y is there any other option to execute .exe file other than Runtime.getRuntime().exec("filename");Write proper English and you may be taken more seriously.
    1) it's not "taking more time to execute", whatever that's supposed to mean.
    2) there's no other way to execute something. Not that you should every use even that way anyway
    3) whenever you start thinking of executing external programs from Java, start thinking of not using Java in the first place.

  • Problem while executing batch file via jsp

    Scenario 1+
    I have a batch file(.bat) in which i have the following code
    mkdir d:\test\test1;
    mkdir d:\test\test2;
    mkdir d:\test\test3;
    mkdir d:\test\test4;
    mkdir d:\test\test5;
    mkdir d:\test\test6;
    mkdir d:\test\test7;
    mkdir d:\test\test8;
    mkdir d:\test\test9;
    mkdir d:\test\test10;when i double click on this or execute via cmd all the 10 directories are created successfully.
    Scenario 2+
    But when i try to execute this through a jsp using the following code,Only first 5 directories are created.Please help me in resolving the issue ASAP.Thanks in advance
    <%@page import="javax.swing.*"%>
    <%@page import="javax.swing.JFileChooser"%>
    <%@page import="java.awt.event.*"%>
    <%@page import="java.awt.*"%>
    <%@ page import="java.io.*"%>
    <%@ page import="java.util.*"%>
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
        <title>untitled2</title>
      </head>
      <body><%
            Runtime.getRuntime().exec("d:\\test.bat");
                    System.out.println("Inside Try Block");
                  %>
        hi</body>
    </html>I am using Jdeveloper.

    carrera wrote:
    Then can u suggest any other way how i can invoke a batch file from html/jsp.I think what some of the previous posters wanted to make clear is that jsps are not the place to go calling batch files. Jsp's are normally the view part and don't actually trigger these type of actions directly. Call a servlet to do non-view things...
    If all you want to do is execute an ant file, look for examples for running ant through java api. f.i. here

  • Dbc file and Jsp error

    Dear all,
    I am trying to do multinode installtion on AIX 5.3 HACMP . During post installation i am getting this error.
    Dbc file and Jsp error
    Updating Server Security Authentication
    java.sql.SQLException: Io exception: Invalid number format for port number
    Database connection to jdbc:oracle:thin:@host_name:port_number:database failed
    Updating Server Security Authentication failed with exit code 1
    adgendbc.sh exiting with status 1
    ERRORCODE = 1 ERRORCODE_END
    SQLPLUS Executable : /mglapp/oramgl/mglora/8.0.6/bin/sqlplus
    SP2-0642: SQL*Plus internal error state 2165, context 4294967295:0:0
    Unable to proceed
    ERRORCODE = 1 ERRORCODE_END
    Thanks in advance

    Maybe you have problem with the date format, please ensure that NLS_DATE_FORMAT env variable is set to a valid value.
    Please view SP2-0642: Sql*Plus Internal Error State 2165, Context 4294967295:0:0 Doc ID: Note:396154.1.
    Hope it helps.
    Adith

  • Remove odbc system dsn using batch file and odbcconf

    I create user system dsn entries by using a batch file and odbcconf call.  I've found references here on how to do that, yet cannot seem to find any results on how to remove them using that same call.  The library information (http://msdn.microsoft.com/en-us/library/ee388579(VS.85).aspx) states add and modify a system dsn for configdsn and configsysdsn and references equivalent to SQLConfgDataSource function. (http://msdn.microsoft.com/en-us/library/ms716476(VS.85).aspx) but the config data source function has a a removal and this doesn't seem too. 
    Apologies for being obtuse, but I can't seem to locate it.  Any links to how this is done from a batch file are much appreciated.
    Regards,
    NR.

    John C is basically correct, you can remove a System ODBC data source via the registry, but there is apparently no way via odbcconf.exe.  That is of course really stupid and poor programming!
    John, however, forgot another important registry entry.  That key deletion he mentioned will disable the odbc connection, but not remove it entirely.  If you just do that and then open the "ODBC Data Source Administrator", you will find the
    connection is still listed, but you can't remove it or modify it.  It becomes completely screwed up! There is a value to delete as well which dictates if the connection is listed.  Consider it the "header" to the data source.
    Also, in Windows 2003 and 2008 at least, the registry key John C listed is not quite the location to modify either.  This is where to find them in those OSs:
    HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\%DSN%
    or
    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBC.INI\%DSN%
    The "header" I reffered to is a string value in inside a key (not the whole key!)
    HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources
    or
    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBC.INI\ODBC Data Sources
    The string value is the data source name.  This entry must be removed to remove the data source listing entirely.
    Here are some batch snipets for creating and then removing an odbc data source.  I'm leaving out some premiliary chunks, but you can figure it out from here. If you can't, you probably shouldn't be messing with this stuff in the first place!
    In these scripts, I create and remove a 32-bit data source in either a 32-bit or 64-bit version of windows.  The windows folder variable gets set to either "C:\Windows\System32" or "C:\Windows\SysWOW64" depending on the os.  In case you didn't
    know, on a 64-bit machine there is are also 2 differrent versions of the "ODBC Data Source Administrator" gui tool and the data source lists differ (32-bit vs 64-bit lists).  The 32-bit version on a 64 bit OS is found at "C:\Windows\SysWOW64\odbcad32.exe". 
    The one in the start menu will load the 64-bit version so you will never find your 32-bit connections there.
    Note - for simplicity I use the database name as the user name and and the data source name as well (in case there was any confusion). 
    Create the connection like so:
    echo Creating 32-Bit System ODBC Connection "%DatabaseName%"...
    "!WindowsFolder!\ODBCCONF.EXE" CONFIGSYSDSN "!ODBCDriver!" "DSN=%DatabaseName%;Server=localhost;Port=3306;Database=%DatabaseName%;UID=%DatabaseName%;PWD=%DatabasePassword%"
    And then remove it like this:
    echo Removing 32-Bit System ODBC Connection "%DatabaseName%"...
    if "%WindowsBits%"=="32" (
    If Exist "!TempRegFile!" Del "!TempRegFile!"
    echo Windows Registry Editor Version 5.00>>"!TempRegFile!"
    echo.>>"!TempRegFile!"
    echo [-HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\%DatabaseName%]>>"!TempRegFile!"
    echo [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources]>>"!TempRegFile!"
    echo "%DatabaseName%"=->>"!TempRegFile!"
    regedit /s "!TempRegFile!"
    ) else (
    If Exist "!TempRegFile!" Del "!TempRegFile!"
    echo Windows Registry Editor Version 5.00>>"!TempRegFile!"
    echo.>>"!TempRegFile!"
    echo [-HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBC.INI\%DatabaseName%]>>"!TempRegFile!"
    echo [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBC.INI\ODBC Data Sources]>>"!TempRegFile!"
    echo "%DatabaseName%"=->>"!TempRegFile!"
    regedit /s "!TempRegFile!"
    If Exist "!TempRegFile!" Del "!TempRegFile!"

  • Batch file and PKZIPC utility

    I call a batch file from Oracle forms by clicking on a button. The batch file calls pkzipc utility to extract the contents of a zip file, and place it in the destination xyzfolder. However, this is not working.
    The batch file and PKZIPC are located on the same server. When I run the batch file on the server, pkzipc utility works fine. When I call the batch file from Oracle forms, then the utilty is not working.
    When-button-pressed trigger has the following code:
    declare
    the_command varchar2(2000) := '\\ABCserver\ABCfolder\abcd.bat';
    begin
    host(the_command);
    message('done');
    end;
    batch file code :
    cd "\\ABCserver\c$\Program Files\PKWARE\PKZIPC"
    pkzipc -extract -silent -nofix -overwrite -directories -logfile \\ABCserver\c$\xyzfolder\26.zip \\ABCserver\c$\sssfolder
    exit
    How do I resolve this ?
    Thanks
    SR

    The HOST command likely does not have permission to access a file across a network share. This is probably a Windows restriction and has nothing to do with Oracle. Windows Services do not have permission to access shares. Because Forms is a child process to OPMN (which run as a Win Service) the HOST executed from Forms is probably restricted too. For testing to prove this theory, put all the files on the Application Server and it will probably work correctly. Of course the batch code will need to be changed to reflect the local drive and directories.

  • Executing batch File from Jsp

    I want to execute a batch file which is located at d:\build from a jsp
    I also want to give parameters to batch file.
    Actually my batch file is demo.bat and i want to execute this command via jsp
    demo Compile dev

    in a word - don't. that's not what jsps are for.
    you sound confused about where jsps actually run. get client and server straight in your head and then think about it again.
    %

  • How to execute batch file from JSP

    hi frens !
    i wanna know how to execute batch file from my JSP.i am using exec() method to get call the batch file. but its not working ....plz help
    here mine code:-
    File F = new File("C:/var.bat");
         try{
          if (F.exists())
            Runtime rt = Runtime.getRuntime();
            String url=F.getAbsolutePath();
             Process proc = rt.exec(url);
            proc.waitFor();
            proc.destroy();
            catch(Exception IOEx){
           System.out.println(IOEx);
      }Thanks and Regards
    Allwyn

    You might improve your chances of getting help if you do two things:
    1) Explain what "not working" means.
    2) ChangeSystem.out.println(IOEx); to IOEx.printStackTrace(); (in the eventhat is in fact related to "not working").

  • Installing Oracle 11gR2 client from a batch file and it returns before done

    Hello,
    While installing Oracle 11gR2 client on XP and 7 from a batch file. When it launches the OUI from the batch file, it returns to the batch file before the installer finishes. So, there is no way for my script to know when the installer is done, or to glean a return code to test for success. This is particularly annoying...
    I've also used the "call" command to force my batch file to wait, to no avail. Anyone have any clues about this one?
    Thanks in advance!
    --Robert                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Srini,
    Awesome! Worked like a charm.
    Many thanks!
    --Robert                                                                                                                                                                                               

  • Two questions: Executing batch files and executing a JAR on boot-up.

    I'm working with Windows XP and and currently I'm having a friend test this on Vista as well. I can't seem to find how to execute a batch file using Runtime.exec(). So far I've been passing the absolute pathname of the batch file as the argument to exec(), but it doens't seem to run, so I'm assuming there's another way.
    Second question, how do I get a JAR file to start running whenever the user turns on the PC?
    Thanks.

    I'm working with Windows XP and and currently I'm
    having a friend test this on Vista as well. I can't
    seem to find how to execute a batch file using
    Runtime.exec(). So far I've been passing the
    absolute pathname of the batch file as the argument
    to exec(), but it doens't seem to run, so I'm
    assuming there's another way.Are you using just Runtime.exec() or have you tried Runtime.getRuntime().exec()? If not, try that and see what happens.
    Second question, how do I get a JAR file to start
    running whenever the user turns on the PC?As far as I know, you can't do that programatically. You have to edit settings on your computer but I am not entirely sure.
    Thanks.

  • How do I start a batch file and check it's status?

    First of all I want to say I am a beginner in Java.
    I am working on an server side application that starts batch files (for database filling). After it starts the batch (.bat) file it has to check the status and write it in the database.
    The problem I run into the combination of starting the batch and checking the status.
    So far I have found out that I can run the batch file with starting up an process with the Runtime.getRuntime().exec command. What I haven't found out if it is posible to check the status of this proces in any way.
    I also found out that with using thread commands like isAlive I can check the status of a thread, but not of an process. And I understand that a thread can't start an batch file.
    So could anyone please help me on my way. Am I doing something wrong? Is any of the above info incorrect? Or am I on the right way? And if I am on the right way what is the next step? Thanx in advance.

    The problem I run into the combination of starting
    the batch and checking the status.The exit status is only set onve the process completes.
    process.exitStatus()
    I also found out that with using thread commands like
    isAlive I can check the status of a thread, but not
    of an process. And I understand that a thread can't
    start an batch file.Everything run in java is run from a thread. Only threads can do anything. The default thread is called "main"

  • Cfexecute, batch file, and a ftp script

    I have a batch file which works fine when entered in at the
    command prompt;
    C:/temp/mybat.bat
    but when I use cfexecute it fails.
    Now this may be more of a case of what I am calling than CF
    itself.
    here is the output:
    C:\CFusionMX7\runtime\bin>"C:\Program
    Files\Ipswitch\WS_FTP Professional\ftpscrpt" -f
    C:\temp\poolsite.scp Processing Line 1 [CONNECT pacmed -p] Finding
    Host poolsite... Address lookup of "poolsite" failed. It may be
    misspelled, or your computer may not be connected to the network or
    Internet. Also check that your DNS and local name servers are
    properly configured and responding. Failure in command [CONNECT
    poolsite-p] Processing Line 2 [ONSUCCESS SHELL C:/temp/remove.bat]
    Set [ONSUCCESS] action to [SHELL C:/temp/remove.bat] Processing
    Line 3 [MPUT c:/temp/apptTxfr/*.*] Not Connected Failure in command
    [MPUT c:/temp/apptTxfr/*.*] C:\CFusionMX7\runtime\bin>ECHO OFF
    the very odd thing, is again, when I call this from a command
    line, it works fine.
    are there any wrappers or special ways I need to encapsulate
    this when using cfexecute?

    Thank you for the suggestions. The odd thing though, is it
    looks like it calling the batch file just fine. It's just that for
    whatever reason, the ftp client isn't getting fed the paramters
    correctly. Ie
    Processing Line 1 [CONNECT poolsite-p] Finding Host
    poolsite...
    passing -p tells the ftp client to use a prefdefined site
    profile (poolsite), instead of using the hostname poolsite.
    Basically it is if for whatever reason the ftp program is not
    reading it''s scp file correctly when invoked from CF.
    I'll check out the permissions and report back.
    thanks for the suggestion.

  • Batch file, and installing a executable​.

    I'm pretty new to LabVIEW.  Anyways, I need to create a makefile that will install the LabVIEW runtime engine, and several LabVIEW user created executable VIs into specific directories determined by environmental variables within the makefile.  I've been looking around, and all I can find is batch file stuff.  Any ideas would be appreciated.  Thanks.
    In short, I need LabVIEW RTE, and several labVIEW created executables installed on target machine via a makefile.
    Sebastian 

    Todd has pointed you in the correct direction.
    I tested this with an LV2009 installer that does not contain the LVRTE. I do not use make files (not a C coder) but think they may run applications like a batch file (if not, use a batch file).
    1. Create the installer for your LV app and point the top level to install in single generic folder (c:\temp).
    2. Include the other executables you mentioned as line items.
    3. Run the installer locally to generate a installation spec file: 'setup.exe /generatespecfile myspec.ini'
        (The only question I noted was about the install folder which I set to #INSTALL_FOLDER#)
    4. Open the generated 'myspec.ini' file and find the 'set install directories' area and you should find:
            <RootDirectory1>=#INSTALL_FOLDER#.
    5. For my confirmation test, I changed this to 'c:\testInstall'.
    6. Run the installer using the updated spec file (add the later parts for auto install; for silent, use just /q):
              'setup.exe myspec.ini /qb /acceptlicenses yes'
    From your makefile (or batch file), you should be able to update the #INSTALL_FOLDER# string in the intermediate spec file (myspec.ini) to the contents of the environment variable you want by simple string replacement then run the installer as shown in (6).
    good luck

  • Brain freeze with batch file and jar

    My batch file located in the startup folder.
    @ECHO ON
    Set Path =C:\Program Files\My-App\jre\bin
    cd C:\Program Files\My-App
    javaw -cp C:\Program Files\My-App\Startup.jar; SrvcUtilTest
    EXITthe error I get is "Could Not Find Main Class. Program will exit"
    If I take the Set Path line out it works fine, but my customers will not have the JRE installed on their systems,so I set the path to the jre included with my app..
    What am I missing or forgeting to do.
    What am I missing

    Nevermind, fixed it.
    Moved the jar into the startup folder, added a manifest file and changed this line
    javaw -cp C:\Program Files\My-App\Startup.jar; SrvcUtilTest
    to
    javaw -jar Startup.jar
    Works now

  • Diference between a batch file and jnlp file

    Dear all,
    I have a question that might sound simple, but excuse me, coz I am new to jnlp.
    I run my appliction using a simple batch file:
    set JAVA_HOME=C:\j2sdk1.4.2_05
    @set RUN=%JAVA_HOME%\bin\java.exe -Xms32m -Xmx128m -classpath .;myapp.jar pack.app.Main -connection jdbc:oracle:thin:@10.0.0.1:1521:ABC -webroot http://10.0.0.2:8080/test
    %RUN%
    The jnlp file I use to start the same application is:
    <jnlp codebase="http://10.0.0.2:8080/test/app">
    <information>
    </information>
    <security>
    <all-permissions/>
    </security>
    <resources>
    <j2se version="1.4+"/>
    <jar href="myapp.jar"/>
    </resources>
    <application-desc main-class="pack.app.Main ">
    <argument>-codebase</argument>
    <argument>http://10.0.0.2:8080/test/app</argument>
    <argument>-webroot</argument>
    <argument>http://10.0.0.2:8080/test</argument>
    <argument>-dbrpc</argument>
    </application-desc>
    </jnlp>
    I encountered two problems:
    1. The aplication hangs when I click certain buttons, which is not the case when I run it normally from the batch file.
    2. Some buttons do not even appear, where they appear normally using the batch file.
    I would appreciate any hints that could help.
    Samar

    You could make a self extracting EXE with WinZip, and then do something like..  (You would create an application with source files to do this, with the below code being your 'install.bat')
    @echo off
    xcopy "AppFiles.exe" %WINDIR%\Temp
    %WINDIR%\Temp\AppFiles.exe
    %WINDIR%\Temp\AppFiles\Install.exe
    RMDIR /S /Q %WINDIR%\Temp\AppFiles
    If you monitor the install and your satisfied its working correctly, you can modify the success return codes under the 'Option' tab, or just check the box 'Continue on Error' to keep the build rolling after this install is complete.  Additionally, you
    may find this works better as VBS script.

Maybe you are looking for

  • Can you transfer iTunes from an orphaned iPhone (laptop it used to synch to was stolen)...

    My son has an orphaned iPhone with music we'd like to synch to our main iMac (his laptop which had his library was stolen).  Is there some way to transfer the songs from his iPhone?  They were purchased using my appleID, so in theory they are mine. 

  • ITunes has encountered a problem and needs to close message

    I started getting this message after downloading a free video I got through Starbucks. At this same time I purchased a video and downloaded it. At first I just couldn't manually drag the video into my iPod and then whenever I tried to play any video,

  • PS Elements Properties display on TV

    When I export images from Adobe PS Elements to a flash drive for display on TV, how do I include the Properties text that I enter for each image as an explanation of the image's significance?

  • Restore Database on New Host in Catalog mode

    Dearest DBAs, Here is RMAN configuration details, 163.19.0.153 Production Database (orcl) 163.19.0.154 RMAN Catalog Database (rman) 163.19.0.155 BackupSets Location 163.19.0.156 Test Machine I have taken the backup through RMAN and now want to restor

  • N95 V12 firmware withdrawn?

    Has V12 firmware been removed from the Nokia update site. Tried updating my N95 this evening and was only offered the same V11 that I already have to reinstall.