Replacing browser page after POSTing to CGI

W

WagnerR

I have an applet which needs to submit to a CGI via POST. I want the results of
that POST to be shown in a new web page. I can do this with a GET by creating
the URL for the CGI and parameters and using
getAppletContext().showDocument(url), and the browser changes its URL to that
of the CGI and the results from the CGI are displayed in the new page.

Is there a way to do this via a POST operation? I have seen the various code
samples for submitting a POST via URL, HttpURLConnection, etc., and can even
read back the results, but don't know how to get the results into a new page in
the browser.

Thanks,
Ron
 
J

John C. Bollinger

WagnerR said:
I have an applet which needs to submit to a CGI via POST. I want the results of
that POST to be shown in a new web page. I can do this with a GET by creating
the URL for the CGI and parameters and using
getAppletContext().showDocument(url), and the browser changes its URL to that
of the CGI and the results from the CGI are displayed in the new page.

Is there a way to do this via a POST operation? I have seen the various code
samples for submitting a POST via URL, HttpURLConnection, etc., and can even
read back the results, but don't know how to get the results into a new page in
the browser.

The AppletContext is your connection between an Applet and its
environment (browser, applet viewer, whatever). That's what's available
for you to work with. AppletContext.showDocument() does not offer a
means to specify the request method, so you have two options, neither
particularly good:

(1) If you have control of the web server, set it up so that you can get
the page you want via a GET. There are two suboptions I can think of
(1a) Make the page of interest handle GETs the same as POSTs by
accepting the necessary parameters in the query string. You may even
find that it already does.
(1b) Configure the web application so that after posting you can obtain
the same response by a subsequent GET (so you POST the data, ignore the
response, and direct the AppletContext to display a suitable URL,
thereby receiving the same response)

(2) If your applet is trusted then you can POST the request and write
the response to a suitable temporary location on the local disk, then
direct the AppletContext to display the document from the local disk.
If you do this then you might be wise to insert a suitable <base>
element into the document's header so as to cause relative URLs in the
document to resolve correctly.

If neither of the above is available to you then I think you're SOL.


John Bollinger
(e-mail address removed)
 
W

WagnerR

OK, I was hoping there was something available in Java I didn't know about. I
don't control the server side on this project but the existing CGI will take a
GET.

Thanks,
Ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top