question

ChamandeepSingh-6114 avatar image
0 Votes"
ChamandeepSingh-6114 asked MotoX80 answered

Run .jsp script in task scheduler

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MotoX80 avatar image
0 Votes"
MotoX80 answered

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://docs.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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered

Hello @ChamandeepSingh-6114

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,

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.