OutputStream rawOutStream = huc.getOutputStream(); // I get the HTML page. BUT... FORM is NOT submitted automatically with the "document.WOTASK.submit();"
What I can do:
I can connect ang get HTML page. BUT... FORM is NOT submitted automatically with the "document.WOTASK.submit();"
I can call Sample.jsp from my firefox web browser and the JSP page connects and submits page.
I can create a vbscript which instantiates a web browser class and the JSP page connects and submits page.
What I can not do:
Create a Java program which runs on a UNIX server that can connect to web server and call a JSP page which performs java scripting code.
No Browser application.
Is there a Java class which can be used to call&execute a JSP page within JAVA?
JSP creates HTLM, which requires something to interpret and display it. What are you intending to use instead of a browser? If there is nothing to display, would it not be better to just use RMI or something?
"JSP creates HTLM, which requires something to interpret and display it. What are you intending to use instead of a browser? If there is nothing to display, would it not be better to just use RMI or something? "
That I understand, what I don't understand is why you have chosen to use GUI and client side technologies when neither are needed. Is there something I'm missing? If not, and if you ultimately are looking for an HTTP request with some parameters already set, you would probably find it much easier just submitting an HTTP request directly from Java. Have a look at the java.net package.
"why you have chosen to use GUI and client side technologies when neither are needed."
Paul, I am sure you are correct. I don't know how to call a servlet. I can view an existing JSP page and modify the code to automatically submit the form. I am using GUI and client side technologies because they provided a successful starting point. I am not familiar with RMI but it doesn't appear that I can call a servlet.
"submitting an HTTP request directly from Java. Have a look at the java.net package. "
I will look at the java.net.package again. Maybe the ContentHandler
The servlet processes records in a queue. There are four types of records in the queue. I need to pass a parameter to the servlet identifying the type of record to process. A return code would be nice. Currently i query a database to determine number of rows unprocessed. Zero rows means success.
I imagine the best way is to call the servlet directly with params. But I believe the servlet references request html fields for parameter values. The servlet is vendor supplied and I don't believe I have source code.
The Servlet will not request HTML fields, because HTML doesn't come into play where the actual request is concerned (HTML is just a GUI technology really). Ultimately it must pass specific parameters in the request (because that's how HTTP works), and these should be discoverable by looking at the source generated when you access it via a browser. I'd maybe use the UI and watch what params are passed with a tool like Fiddler (if its not immediately obvious from looking at the source) and see if you can replicate in a simple class. In theory this should be much simpler than having to invoke a browser instance on the fly.
The point is that you don't need a JSP at all. Just submit a request that hits the servlet with the appropriate information. You are creating a Rube Goldberg machine to do something that is actually quite simple.
I can connect with
URL myURL = new URL("http:\\Server:8080\whatever\whatever.jsp);
HttpURLConnection con = (HttpURLConnection) myURL.openConnection();
// con.getResponseCode() returns 200 OK
How can it I con.submit("servlet/PollerMaintenance&Parameter1="value1"&Parameter2="Value2);
Instead of the URL of the JSP, just hit the URL of the servlet. I'm not sure why you have it so stuck in your mind that a JSP must be used to contact a servlet. It's just addressed by URL in the same way that a JSP, or HTML or anything else is addressed.
URL url = new URL("http://192.168.1.101:8080/servlet/PollerMaintenance");
URLConnection conn = url.openConnection();
BufferedWriter out =
new BufferedWriter( new OutputStreamWriter( conn.getOutputStream() ) );
BufferedReader in =
new BufferedReader( new InputStreamReader( conn.getInputStream() ) );