Run .jsp script in task scheduler

Chamandeep Singh 41 Reputation points
2021-09-02T04:45:55.227+00:00

Hi,

OS = Windows Server 2019

I need to run a .jsp script in task scheduler

Scripts is http://X.X.X.X:8080/DeleteLog/DeleteLog.jsp

In task scheduler, under start a program option tab,

There are three fields - I am trying these options

Program/Script - don't know what to use?
Add argument - http://X.X.X.X:8080/DeleteLog/DeleteLog.jsp
Start in - C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\ROOT\DeleteLog

Can someone please tell me what will come in the Program/Script option

or what is correct process to run a .jsp file in task scheduler

Windows Server 2019
Windows Server 2019
A Microsoft server operating system that supports enterprise-level management updated to data storage.
3,613 questions
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 32,911 Reputation points
    2021-09-03T02:40:35.367+00:00

    You cannot run a web page in the task scheduler. You need to run an executable program, like cscript.exe or cmd.exe, or java.exe, or perl.exe, or any other .exe. These are typically command line programs. You can run a GUI program but they normally expect to interact with a user who will "click on OK to continue" and don't always work well when run as a task.

    Now, you can run a script to invoke a web page. Powershell has Invoke-webrequest.

    https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-5.1

    You would need to write a .ps1 script to call the page, The program is Powershell.exe and the argument is the full path to the .ps1 script file. Note that the .jsp page will execute in the memory of whatever server hosts the web site. That is not necessarily the same machine that is running the task. It could be, but the Powershell script is not going to magically invoke a remote jsp on the local machine that runs the task.

    https://www.tutorialspoint.com/jsp/jsp_architecture.htm

    A jsp page expects to be invoked within the context of an HTTP request between a client and a server. A Task Scheduler task is essentially a command line environment. They are not the same.

    Based on the name, if the .jsp purges Tomcat logs from the remote web server, then a Powershell .ps1 which does an Invoke-WebRequest should work for you. I would expect the page to require authentication, so you will need to add in credentials on the call.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Limitless Technology 39,511 Reputation points
    2021-09-02T16:29:30.477+00:00

    Hello @Chamandeep Singh

    Program/Script - your .jsp file http url or path of .jsp file.

    Add argument : <Leave blank >

    Start in - C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\ROOT\DeleteLog

    Thank you,

    0 comments No comments