First let me state upfront that I'm a Java programmer, not a web developer.
Consequently I may be flying a bit wild here...
I have scoured the web and usenet for solutions on how to communicate with a
stand-a-alone Java application from a web page. Sounds like there is no
really good browser independent way other than with applets.
Here is what I am trying to do...
I want to load a document with two frames. The top frame basically just has
a button that says something like "Analyze". The bottom frame is initially
loaded up with some web page. The user may browse around via links in the
bottom frame and go to arbitrary web pages which will be loaded in the bottom
frame.
When the user clicks the "Analyze" button, I want to send the URL in the
bottom frame to my Java application for analysis. Both the application and
the web browser are on the same machine. The analysis is really displayed in
the application, so no real results need be displayed in the browser.
I was thinking about using a form post to post to my application (listening
on a special port). I would use a "hidden" form element to send the url for
analysis. This seems to be pretty much working for me. Here is the form
code:
<form action="http://127.0.0.1:7333/results.html" method="post">
<input type="submit" name="foo" value="Analyze Page">
<input type="hidden" name="url_to_parse" value="someurl">
</form>
So I'm posting to the loopback address on port 7333 where my Java app is
listening. The Java app does get data on the port and reads it and generates
some returned text that does get displayed.
My questions:
1. Is there anything fundamentally wrong with doing this this way?
2. Ideally I'd like the post to not change the web browser display, but if I
don't return something the browser says "The page contained no data". Any
way around this?
3. I seem to need to have the form action post to a (bogus) .html file.
Otherwise the browser thinks it needs to download the result as a file. Is
there a better way to handle this?
4. Eventually, I need to build the page that has the forms and I need to
on-the-fly replace the "someurl" with the url loaded in the bottom frame. I
assume I need javascript to do this. Anyone want to post a code snippet to
do what I need (I really know very little about javascript).
Thanks so much for any help or suggestions.
--
Bill Tschumy
Otherwise -- Austin, TX
http://www.otherwise.com