Hi to All, I am having a problem here. It would be kind of you to let me know how i vcould proceed further how to execute a file(jsp) from main method? a jsp file will publish the content to the database, actually some database updation has to be done . this jsp has to run every day at particular time automatically . The unix scheduler is already there now i have to prepare a java main class to execute the jsp file...... I am new to JSP and dont have knowledge about it . Any reply woul dbe highly appreciated . Many Thanks Bye L.John
To take what you want to do (literally), you are asking how to send an Http Request to a JSP from a cmdline application. Without knowing too much about what your requirements are, to call a JSP/Servlet/cgi-bin process you just need to use the java.net.* APIs. In particular java.net.URL and java.net.HttpURLConnection. Your "main()" will issue an Http request to the JSP in question. The idea is that you need to know which parameters need to be passed into the JSP to make it function. You will end up producing something like (depending on whether you want to POST or GET):
Anyway here is some example code to get you started (it attempts to do an HTTP POST):
Things can get a bit more complicated if there are firewall/proxy issues and also if some sort of authentication is done against the JSP, if so, send more details. James.
Hi, As one of our member has said, why do you need a jsp here? In your doubt, it is not clear that, where the contents needs to be displayed. If it is to be displayed on the browser, why don't you use a Servlet with a proper thread implementation which will access the data from the db and make updations if necessary and display the content in daily basis?. Thanks
subject: Imp-How to execute a JSP file from java main