way 2 sms : getting the token value can be done using this code

import java.net.*;
import java.io.*;

class JavaUrlConnectionReader
{
  public static void main(String[] args)
  {
    String output  = getUrlContents("http://site21.way2sms.com/content/Login1.action?username=9999999999&password=neeth99&loginBTN=Login");
    System.out.println(output);
  }

  private static String getUrlContents(String theUrl)
  {
    StringBuilder content = new StringBuilder();

    // many of these calls can throw exceptions, so i've just
    // wrapped them all in one try/catch statement.
    try
    {
      // create a url object
      URL url = new URL(theUrl);

      // create a urlconnection object
      URLConnection urlConnection = url.openConnection();
System.out.println( "orignal url: " + urlConnection.getURL() );
      // wrap the urlconnection in a bufferedreader
   
      urlConnection.connect();
System.out.println( "connected url: " + urlConnection.getURL() );
InputStream is = urlConnection.getInputStream();
System.out.println( "redirected url: " + urlConnection.getURL() );
is.close();
}      
    catch(Exception e)
    {
      e.printStackTrace();
    }
    return content.toString();
  }
}




Output: 


orignal url: http://site21.way2sms.com/content/Login1.action?username=9999999999&password=neeth99&loginBTN=Login
connected url: http://site21.way2sms.com/content/Login1.action?username=9999999999&password=neeth99&loginBTN=Login
redirected url: http://site21.way2sms.com/vem.action;jsessionid=8E76B48271B3A594FB4F73A88663D475.w806?id=8E76B48271B3A594FB4F73A88663D475.w806



Output: 



orignal url: http://site21.way2sms.com/content/Login1.action?username=9999999999&password=neeth99&loginBTN=Login
connected url: http://site21.way2sms.com/content/Login1.action?username=9999999999&password=neeth99&loginBTN=Login
redirected url: http://site21.way2sms.com/vem.action;jsessionid=F1955F8F5DBC8725C453D80D69A39D07.w801?id=F1955F8F5DBC8725C453D80D69A39D07.w801



Comments