Results 1 to 8 of 8
- 08-18-2010, 11:36 AM #1
POST information to html form via java?
I've been trying to work this out for a while now but cant seem to do it. I've downloade various different source codes but none seem to work ann they all use slightly different techniques. Basically im at a total loss
Could someone point me in the right direction or show me some proven source code they've used to get this to work.
What im trying to do is use a search engine which is similiar to google.
And im trying to use the POST method to send information to that form via a form that ive made in java, and then display the results.Teaching myself java so that i can eventually join the industry! Started in June 2010
- 08-18-2010, 01:22 PM #2
There are sample code bits on the forum. To do a POST requires calling a set method before outputting the text of the post data. I forget the method name. Do a Search here for URLConnection or POST
- 08-18-2010, 07:01 PM #3
I think you have to use the GET method because of the action name on the form. I tried using POST and I get HTML error 405. HTTP Error 405 Method not allowed Explained
"Experience is what you get when you don't get what you want" (Dan Stanford)
"Rise and rise again until lambs become lions" (Robin Hood)
- 08-18-2010, 09:50 PM #4
It depends on what the server wants to receive: GET or POST.
You can't assume it will accept either one. Look in the HTML that you are using for your source of <FORM contents.
- 08-19-2010, 01:54 AM #5
I have looked @ that. What would you send if the action name is "/search" via POST? This is what I came up with and I'm getting an exception:
Java Code:GoogleOut.write("hl=en&source=hp&ie=ISO-8859-1&q=Java+Tutorials&btnG=Google+Search");"Experience is what you get when you don't get what you want" (Dan Stanford)
"Rise and rise again until lambs become lions" (Robin Hood)
- 08-19-2010, 02:14 AM #6
I'm not sure what the GoogleOut.write() method does. Its arg looks like a query string.
What I was talking about is in the HTML file loaded into a browser. The <FORM tag defines if the query is a GET or a POST by its METHOD= attribute.
<FORM ACTION="http://127.0.0.1:8081/Test_Upload" METHOD=POST ENCTYPE="multipart/form-data">
- 08-19-2010, 02:53 AM #7
Yes that's what I'm talking about too. For my <form tag I have this:
I was told that if no method attribute is there, I was to assume its method is GET.Java Code:<form action="/search" name=f onsubmit="google.fade=null"><table cellpadding=0 cellspacing=0><tr valign=top><td width=25%> </td><td align=center nowrap>
"Experience is what you get when you don't get what you want" (Dan Stanford)
"Rise and rise again until lambs become lions" (Robin Hood)
- 08-20-2010, 06:01 AM #8
Similar Threads
-
where to post questions about javascript in html?
By iansane in forum Forum LobbyReplies: 2Last Post: 05-26-2010, 04:12 PM -
want to generate a html form page with dynamic data and submit this form to a url
By vishalkrsrivastava in forum Java AppletsReplies: 10Last Post: 08-12-2009, 04:02 PM -
Responding back to application's HTTP POST values with application/x-www-form-urlenc
By jeremy.wilson in forum New To JavaReplies: 1Last Post: 08-05-2009, 02:43 AM -
Help in reading values from html form in java
By ichkoguy in forum Advanced JavaReplies: 7Last Post: 03-16-2009, 07:45 AM -
add information to HTML file
By newbieal in forum New To JavaReplies: 2Last Post: 10-03-2008, 08:59 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks