Forums Register Login

How do I respond to a webpage that contains a javascript?

+Pie Number of slices to send: Send
Hi All,
I am trying to write a Java standalone app (not an applet) that reads a webpage across the net and then responds to it (with a user and password on the first page).
I have got as far as creating an HttpsURLConnection, connecting to it, reading from it and printing the resulting page source which includes a <SCRIPT> tag. Now I want to send something ( a page? a PUT? Run a javascript that sends stuff? I don't know what ) back to the server.

As far as I can see, when the page is displayed in a browser, the script sends the user and password values from the screen back to the server. I have the user and password values available in the app but don't know what to do with them.

I have spent the morning trying to get direction for the next move ( Eg. I found Rhino and jQuery but they seem server-oriented and overkill ). Maybe I just need a subset???

Can anyone point me in the right direction as to how I buld up and send a response? That is, I know how to getOutputStream() and write to it but I don't know what to write.
Should I be trying to run the javascript script from Java (if so how?) or just doing some kind of 'POST' back to the server (if so what format?)?

Sorry for asking about what has clearly been done a million times before but I am going in Googlic circles at the moment.
All constructive comments gratefully received.
+Pie Number of slices to send: Send
You need to bone up on how HTTP works. I've moved this to a more appropriate location.

In HTTP, when you send the request for the page to the server, it responses by sending you the body of the HTML page as its response. That transaction is not done, You do not respond to it it any way. If you want to talk to the server again, you do so with another request.
+Pie Number of slices to send: Send
Thank you, sorry for abusing the boffins' forum.

Could you pass some clues on how I pass a second request that looks (to the server) as if it came from the javascript that the server just sent me?
+Pie Number of slices to send: Send
The Apache HttpClient library makes this relatively easy (there are lots of examples on its web site), as does the HtmlUnit library.
+Pie Number of slices to send: Send
Thank you Ulf, I will have a look at the httpClient.
Everybody! Do the Funky Monkey! Like this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 879 times.
Similar Threads
Passing values to and from HTML
what streams to use for inputing and outputing an character array over a socket
About the book
NT login - triggered by Java App
Multiple submissions
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 02:42:48.