• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 284
  • Last Modified:

placing textfield values to website

Hi,

Isit possible for me to add values onto a form on a website that isn't mine?
I need to pass the string values that was taken from the textfield on the java app and place it on the site on
http://websms.starhub.com/websms/sendSMS/index.jsp

Is there any source code that is related, can show me? Thanks
0
TPoly
Asked:
TPoly
  • 10
  • 10
  • 3
  • +2
2 Solutions
 
girionisCommented:
You should be able to post the form. Look at the site and see where the post request goes. Then use the same URl and post your values there.
0
 
girionisCommented:
And here is how you can send a POST request: http://javaalmanac.com/egs/java.net/Post.html
0
 
girionisCommented:
You need to post a request to this page:

p_sendSMS.jsp

and pass the following variables:

mobileR
name
msg

Use the example I posted from the javaalmanac and replace the URL and the names of the values with the names and the URL above.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
TPolyAuthor Commented:
@girionis:
I've tried the above ways, and also including some hidden values that are inside the site.
and its still doesn't work
0
 
girionisCommented:
Do you get any error messages? This is the way it is done.
0
 
TPolyAuthor Commented:
I tried sending the whole chunk of url with the values to the site and it just redirect back to the default site.
no errors or anything.
0
 
girionisCommented:
Hmm... not sure what could be going wrong, maybe it needs some kind of authentication after you try to send the message?
0
 
TPolyAuthor Commented:
Which means sending the values through this site is most prob impossible?
0
 
TPolyAuthor Commented:
Or is there anyway to retrive the authentication key or something?
0
 
girionisCommented:
You should be able to authenticate also, by using the same way, sending a POST request.
0
 
TPolyAuthor Commented:
erm.. can you show me an example of sending authenticate by a POST request?
0
 
girionisCommented:
0
 
girionisCommented:
Make sure it is password protected first. It might not be and we might be looking at a completely wrong direction. The best thing would be to have a look at the site's logs. do you have access there?
0
 
TPolyAuthor Commented:
no access at all, just a public user there.. so i don't think the auth can work
0
 
girionisCommented:
Aye, this is true. Do you have access to the server's logs?
0
 
TPolyAuthor Commented:
erm.. nope.. that site is for the public to send free sms to the telco's user
so nothing at all =\
0
 
girionisCommented:
I am stumped... not sure what could be going wrong. Especially if you do not get any error messages it's hard to say what happens.
0
 
Giant2Commented:
Generally WebSites have a acknowledge system.
They can use Hidden values, values masked into others, cookies etc.
It's not easy understand (and break) what is the mainroute used by a website.
0
 
TPolyAuthor Commented:
is there any other ways? =\
0
 
kumvjuecCommented:
hi,
if the form you are referring to is not a very complicated form, then using junit (httpunit) works better than httpclient. this can work on the same session also.
I am posting the sample code, but you'll have to download junit.

                  WebConversation objwc = new WebConversation();                  
                  
                  //GetMethodWebRequest is used to issue a GET request specifying a URL in the constructor.
                  WebRequest req = new GetMethodWebRequest("http://qaccess/AccessWeb");
                  
                  // getResponse() actually issues the request and retrieves the web page. If getResponse() cannot find the page it throws HttpNotFoundException
                  WebResponse res = objwc.getResponse(req);
                  
                  //Once u get the response u need to parse through it.  Your page has a form with few fields. We need to fill in fields and submit the form
                  WebForm form = res.getFormWithName("convertFrm");
                  System.out.println("Action: " + form.getAction());            //Reading the form action
                  
                  Button [] but = form.getButtons();                   //Reading the buttons in the form
                  for(int i=0; i< but.length ; i++)
                              System.out.println(" Button " + i + " :" +  but[i].getValue() + but[i].getID());
                  
                  String [] str =  form.getParameterNames();                   //Reading the parameters
                  for(int j=0; j< str.length ; j++)
                              System.out.println("Parameter : " + str[j]);

                  //Code for setting parameter and submitting form
                               
                  form.setParameter("srcPdfUrl", ReadStaticPage.currentURL);
                  long secs = (new Date()).getTime()/1000;
                  if (secs % 2 == 0)
                  {
                        form.setParameter("convertTo", "html"); //hidden field
                        System.out.println("Converting to -> html");
                  }
                  else
                  {
                        form.setParameter("convertTo", "text");
                        System.out.println("Converting to -> text");
                  }
                  //form.setParameter("exportType", "html");
                  form.submit();
                  
                  //After form submission, the response can be obtained by reading the current page
                  //res = objwc.getCurrentPage();
                  
                  //Read the InputStream from the Response Object
                  //System.out.println("Content Length: " + res.getContentLength());                  
                  //int b = 0;
                  //String resstr = new String();
                  //InputStreamReader in = new InputStreamReader(res.getInputStream());
                  //while( in.read() != -1);
                        //resstr= resstr + (char)b;
                  //System.out.println( resstr);
                  //in.close();

0
 
kumvjuecCommented:
hope u can work it out for yourself the above thing
0
 
objectsCommented:
grab a http proxy and have a look at the traffic passed when accessing the form using a browser.
0
 
TPolyAuthor Commented:
First it passes the value "mobileR=91838845&isNewSession=true&name=marc&msg=test+message&new=1" to p_sendSMS.jsp

but then it later on connects to another server:

GET http://server-sg.imrworldwide.com/a1.js HTTP/1.0

Accept: */*

Referer: http://websms.starhub.com/websms/session/p_checkSession3.jsp?nR=6591838845&n=testname

so what do i do now??
0
 
objectsCommented:
I'd suggest you go back a step and look at the loading of the original form first, and check what cokkies are being passed.

> so what do i do now??

You need your client to duplicate the behaviour of the browser when making the request(s).
0
 
TPolyAuthor Commented:
@objects:
could u help me check the cookies stuffs?
i don't quite know about all those things
0
 
objectsCommented:
to get the cookie value:

String cookie = connection.getHeaderField("set-cookie");

then to set it in subsequent request:

connection.setRequestProperty("cookie", cookie);
0
 
Giant2Commented:
I suggest a delete (with refund) or a split.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 10
  • 10
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now