wood burning stoves 2.0*
The moose likes Java in General and the fly likes Fill a html form using java. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Fill a html form using java." Watch "Fill a html form using java." New topic
Author

Fill a html form using java.

kamal krishna bhatt
Ranch Hand

Joined: Apr 26, 2011
Posts: 41

hi ,
using java code i need to hit a URL that opens a web page which contains log in/ password/description text boxes and i need to fill all these credentials.
how can i do that.
Arun Chidam
Ranch Hand

Joined: May 08, 2006
Posts: 79
HI Kamal,

please see below a sample code to open the URL with login credentials, you need to invoke this code from a action event.



SCJP 1.4, SCWCD 1.4
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

That will probably not work since the buffers are never read, so they will fill up causing your program to hang. Read more about that here. Also using platform specific code isn't really clean.

Remember that your browser just sends http requests and displays the result. From java you can easily send those http request as well. For instance look at HttpURLConnection.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
kamal krishna bhatt
Ranch Hand

Joined: Apr 26, 2011
Posts: 41

what i actually need to do is i need to send some SMS on the basis of some event happens ,so to access that sms gateway first needed to give login credentials then i reach to have a SMS form in which i need to fill mobile no., sms content,maximum characters etc. and submit.
what i was looking for is to get the source for that page and set the values of specific attributes (i.e. user,password etc.) and submit the html form (as can be done in python) is there any way do that in java.
Arun Chidam
Ranch Hand

Joined: May 08, 2006
Posts: 79
kamal krishna bhatt wrote:what i actually need to do is i need to send some SMS on the basis of some event happens ,so to access that sms gateway first needed to give login credentials then i reach to have a SMS form in which i need to fill mobile no., sms content,maximum characters etc. and submit.
what i was looking for is to get the source for that page and set the values of specific attributes (i.e. user,password etc.) and submit the html form (as can be done in python) is there any way do that in java.


Hi Kamal,

Does your SMS service provider accept SMS via email?, it is very simple if they have standard email to SMS conversion, where you send email as per their standard format and they recieve and process it as SMS request....message format should be something similiar as below....

TO : sms@messaging.xyz.com
Subj : SMS Message for 0XXXXXX id:XXXX user:XXX password:XXXXX to:XXXXXX text:XXXXXXXXX msg_type:SMS_TEXT

You can send the above message using javax.mail.Message API

Thanks
Arun
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

Don't most (all?) SMS gateways provide an API?


luck, db
There are no new questions, but there may be new answers.
Tarun Bolla
Ranch Hand

Joined: Jun 20, 2011
Posts: 89
Hi....

You dont need to meddle with GUI there!!

Wouter Oet wrote:
Remember that your browser just sends http requests and displays the result. From java you can easily send those http request as well. For instance look at HttpURLConnection.


He is correct. You want to look at the HttpURLConnection class. which will do Post or Get on a url and give you the returned HTML content. So that you can extract what ever you need from the obtained content. This is like AJAX if you are familiar with it.....

I think this is a better approach if there is no API for your SMS gateway. API would have done the same thing if there is one.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Fill a html form using java.