Hello:
POST CROSS POSTED HERE TO:
http://www.codeguru.com/forum/showthread.php?t=513068
THANKS
im new on this forum, but i used it sometimes to solve some problems, now i have one that i cant solve it.
I want to logon in a web witch uses a javascript code in his logon form, i tried to pass the logon with a post method code like i have done in other webs login:
String url="http://www.THEURLWHEREIWANTTOLOGIN.com"; HashMap<String, String> data = new HashMap<String, String>(); data.put("NAME", "AAAAAAAA"); data.put("PASS", "BBBBBBBBBB"); URL siteUrl = new URL(url); HttpURLConnection conn = (HttpURLConnection) siteUrl.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.setDoInput(true); DataOutputStream out = new DataOutputStream(conn.getOutputStream()); Set keys = data.keySet(); Iterator keyIter = keys.iterator(); String content = ""; for(int i=0; keyIter.hasNext(); i++) { Object key = keyIter.next(); if(i!=0) { content += "&"; } content += key + "=" + URLEncoder.encode(data.get(key), "UTF-8"); } out.writeBytes(content); out.flush(); out.close(); BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
but in this web that have a login with javascript code doesnt work, and i dont know how to do it. code of login:
<!-- login --><form method="post" action="login.phtml" name="login" style="display:inline"><table border="0" cellpadding="0" cellspacing="1"><tr><td align="right" valign="middle" class="text">Nombre de usuario: <br /><a href="signup.phtml" class="links" title="Registrar">¿Aún no te has registrado?</a></td><td align="right" valign="middle"><input type="text" name="login" size="10" maxlength="10" tabindex="1" style="width:80px;" /> </td></tr><tr><td align="right" valign="middle" class="text">Contraseña: <br /><a href="recoverPassword.phtml" class="links" title="Recuperar tu contraseña">¿te has olvidado?</a></td><td align="right" valign="middle"> <input type="password" name="pass" size="10" maxlength="8" style="width:80px;" tabindex="2" onkeypress="checkEnter(event, 'login')" /> </td></tr><tr><td colspan="2" align="right"><input type="hidden" name="action" value="login" /> <script language="JavaScript" type="text/javascript"> <!-- document.write("<input type=\"hidden\" name=\">> Login\" value=\"-1\" \/>");document.write("<a href=\"javascript:submitForm('login','>> Login')\;\"");document.write(" tabindex=\"3\"");document.write(" class=\"login\"");document.write(" title=\">> Login\"");document.write(">");document.write(">> Login");document.write("<\/a>"); //--> </script> <noscript> <input type="submit" name=">> Login_x" value=">> Login" /></noscript> </td></tr></table></form><script language="javascript" type="text/javascript"> <!-- document.login.elements[0].focus(); // --> </script><!-- login end -->
Someone can help me? thanks.