Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: Problem in a web that uses javascript in his login form

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Problem in a web that uses javascript in his login form

    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:&nbsp;<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;" />&nbsp;</td></tr><tr><td align="right" valign="middle" class="text">Contraseña:&nbsp;<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')" />&nbsp;</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=\"&gt;&gt; Login\" value=\"-1\" \/>");document.write("<a href=\"javascript:submitForm('login','&gt;&gt; Login')\;\"");document.write(" tabindex=\"3\"");document.write(" class=\"login\"");document.write(" title=\"&gt;&gt; Login\"");document.write(">");document.write("&gt;&gt; Login");document.write("<\/a>");
            //-->
          </script>
          <noscript>
    <input type="submit" name="&gt;&gt; Login_x" value="&gt;&gt; Login" /></noscript>
    &nbsp;</td></tr></table></form><script language="javascript" type="text/javascript">
    <!--
    document.login.elements[0].focus();
    // -->
    </script><!-- login end -->

    Someone can help me? thanks.
    Last edited by kamarilla; June 1st, 2011 at 04:53 PM. Reason: adding cros post


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Problem in a web that uses javascript in his login form

    doesnt work
    Can you explain what happens? Do you get error messages? Or bad results? Can you post what you get back or explain what happens?

    Have you looked what the HTML page that the browser returns to the server so that you can generate the same response as the browser does?
    Last edited by Norm; May 31st, 2011 at 05:20 PM.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Problem in a web that uses javascript in his login form

    This thread has been cross posted here:

    http://www.codeguru.com/forum/showthread.php?t=513068

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting


  4. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Problem in a web that uses javascript in his login form

    What happens when you attempt to login?

    Without knowing the URL and having some valid login details, it's almost impossible for us to pinpoint the problem.

    You say you have written other programs which have worked in the past. If this is the case, what's the difference between this one and the working one?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  5. #5
    Junior Member
    Join Date
    May 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem in a web that uses javascript in his login form

    Quote Originally Posted by Norm View Post
    This thread has been cross posted here:
    Problem login in a web login for that uses javascript - CodeGuru Forums

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting
    Hello norm, its true that i have posted in other forum the same ask. i thought that posting on diferent forum , one of them willgave me the answer and i could post it on the other.

    Quote Originally Posted by JavaPF View Post
    What happens when you attempt to login?

    Without knowing the URL and having some valid login details, it's almost impossible for us to pinpoint the problem.

    You say you have written other programs which have worked in the past. If this is the case, what's the difference between this one and the working one?
    JavaPF:

    1- when i try to login it tells me that i have done a bad login, that i have to retry again. (Tipical message when you fail login on a web)
    2- the url where is the login form is ---> URL of the web
    3- i forgot to tell in my first post that i have done it works with a login form that didn't use javascript(only a tipical form with inputs and a button). In this case the login form is composed with input fields and a script on javascript(it works "like" button).

    thanks for your replies. I will be very if someone can help me. Thanks

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Problem in a web that uses javascript in his login form

    Its ok to cross post if you post a link to the other site so anyone trying to help can look at the other site to see if it has already been answered and if so save time by not answering it again.

    Have you looked what the browser returns to the server when it has read the HTML page with the JS? You need to see that so that you can generate the same response as the browser does?

  7. #7
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Problem in a web that uses javascript in his login form

    i thought that posting on diferent forum , one of them willgave me the answer and i could post it on the othe
    I highly recommend the reading the links in Norm's post. You might get an answer with one of the forums you posted to, but there is potential to waste a lot of other people's time who spend time trying to help you with your problem where it could be answered elsewhere. Your problem may not be solved at this point, but without full disclosure of other locations you've posted the contributors to the forum have no idea and may very well move on to one of the other dozens of unsolved posts. This is all explained in detail in the following link: http://www.javaprogrammingforums.com...s-posting.html

  8. #8
    Junior Member
    Join Date
    May 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem in a web that uses javascript in his login form

    Quote Originally Posted by Norm View Post
    Its ok to cross post if you post a link to the other site so anyone trying to help can look at the other site to see if it has already been answered and if so save time by not answering it again.

    Have you looked what the browser returns to the server when it has read the HTML page with the JS? You need to see that so that you can generate the same response as the browser does?
    sorry i dont know hot to do that. can you help me?
    I have been reading the script of login and it look like it write a doc, and then it does this : document.login.elements[0].focus(); i doesn't undestand nothing.

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Problem in a web that uses javascript in his login form

    You need to understand what a browser returns to the server so that you can do the same thing.
    One way to get some insight is to save the page, edit it and change the <form tag's action= to get vs post, load it in a browser, fill in the fields and press login. The URL will show in the browser's location window.

    Your problem now is in the HTML and Javascript.
    It has nothing to do with Java programming.

Similar Threads

  1. JAVASCRIPT DATE DIFFERENCE PROBLEM
    By jai in forum Other Programming Languages
    Replies: 3
    Last Post: April 5th, 2011, 09:11 AM
  2. javascript problem
    By kundan_101 in forum Member Introductions
    Replies: 2
    Last Post: December 30th, 2010, 09:02 AM
  3. JDBCrealm FORM based problem. But BASIC working perfectly alright!
    By salman4u in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: January 27th, 2010, 09:06 PM
  4. Login form on webpage
    By rosebabz in forum JDBC & Databases
    Replies: 0
    Last Post: January 14th, 2010, 10:34 AM
  5. Java Swing :Back Button from one form to another form
    By srinivasan_253642 in forum AWT / Java Swing
    Replies: 1
    Last Post: December 26th, 2009, 09:51 AM

Tags for this Thread