?
Solved

placing textfield values to website

Posted on 2004-09-21
31
Medium Priority
?
274 Views
Last Modified: 2010-03-31
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
Comment
Question by:TPoly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 10
  • 3
  • +2
31 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 12109827
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
 
LVL 35

Expert Comment

by:girionis
ID: 12109838
And here is how you can send a POST request: http://javaalmanac.com/egs/java.net/Post.html
0
 
LVL 35

Expert Comment

by:girionis
ID: 12109851
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:TPoly
ID: 12109900
@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
 
LVL 35

Expert Comment

by:girionis
ID: 12109935
Do you get any error messages? This is the way it is done.
0
 

Author Comment

by:TPoly
ID: 12110003
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
 
LVL 35

Expert Comment

by:girionis
ID: 12110035
Hmm... not sure what could be going wrong, maybe it needs some kind of authentication after you try to send the message?
0
 

Author Comment

by:TPoly
ID: 12110053
Which means sending the values through this site is most prob impossible?
0
 

Author Comment

by:TPoly
ID: 12110057
Or is there anyway to retrive the authentication key or something?
0
 
LVL 35

Expert Comment

by:girionis
ID: 12110114
You should be able to authenticate also, by using the same way, sending a POST request.
0
 

Author Comment

by:TPoly
ID: 12110142
erm.. can you show me an example of sending authenticate by a POST request?
0
 
LVL 35

Expert Comment

by:girionis
ID: 12110152
0
 
LVL 35

Expert Comment

by:girionis
ID: 12110155
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
 

Author Comment

by:TPoly
ID: 12110173
no access at all, just a public user there.. so i don't think the auth can work
0
 
LVL 35

Expert Comment

by:girionis
ID: 12110191
Aye, this is true. Do you have access to the server's logs?
0
 

Author Comment

by:TPoly
ID: 12110205
erm.. nope.. that site is for the public to send free sms to the telco's user
so nothing at all =\
0
 
LVL 35

Expert Comment

by:girionis
ID: 12110215
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
 
LVL 12

Expert Comment

by:Giant2
ID: 12111093
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
 

Author Comment

by:TPoly
ID: 12112370
is there any other ways? =\
0
 
LVL 3

Expert Comment

by:kumvjuec
ID: 12114417
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
 
LVL 3

Expert Comment

by:kumvjuec
ID: 12114429
hope u can work it out for yourself the above thing
0
 
LVL 92

Expert Comment

by:objects
ID: 12117999
grab a http proxy and have a look at the traffic passed when accessing the form using a browser.
0
 

Author Comment

by:TPoly
ID: 12129460
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
 
LVL 92

Expert Comment

by:objects
ID: 12129587
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
 

Author Comment

by:TPoly
ID: 12129741
@objects:
could u help me check the cookies stuffs?
i don't quite know about all those things
0
 
LVL 12

Accepted Solution

by:
Giant2 earned 500 total points
ID: 12187755
0
 
LVL 92

Assisted Solution

by:objects
objects earned 500 total points
ID: 12187833
to get the cookie value:

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

then to set it in subsequent request:

connection.setRequestProperty("cookie", cookie);
0
 
LVL 12

Expert Comment

by:Giant2
ID: 12408000
I suggest a delete (with refund) or a split.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month8 days, 9 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question