adding event work local only ???

  • 14 years ago

    Hi there,

    I try to add an event to a page, so I can simulate a single sign on.

    First: I start test.html which calls a page login.jsp. Then I set the username, the password and submit the loginform back to the server (and then I'm logged in).

    Setting the values of the password and username works when I work (and load) the pages locally. When I cal the same loginpage from a server (Apache + Tomcat 5.0), it does not work. Why? I tried it on both IE as FireFox.

    Code: test.html

    <html>
    <head>
    <title>Test 1</title>
    <script type="text/javascript">
      var lwindow;
     
      function openTest2() {
        lwindow = document.open("http://192.168.1.60:8080/training/home.jsp", "", "");
        if (lwindow.addEventListener) {
          lwindow.addEventListener("load", doonLoadLogin, false);
        }
        else if (lwindow.attachEvent) {
          lwindow.attachEvent("onload", doonLoadLogin);
        }
        else {
          lwindow.onload = doonLoadLogin;
        }
      }
      function doonLoadLogin() {
        var lremDoc = lwindow.document;
        var ltbUsername = lremDoc.getElementById("j_username");
        ltbUsername.value = "an_user";
        var ltbPassword = lremDoc.getElementById("j_password");
        ltbPassword.value = "a_password";
        var lfmLogin = lremDoc.getElementById("loginForm");
        lfmLogin.submit();
      }
    </script>
    </head>
    <body>
    <input type="submit" onclick="openTest2();">
    </body>
    </html>































    Code: login.jsp

    <%@page pageEncoding="UTF-8" errorPage="error.jsp"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    </head>
    <body>
    <form id="loginForm" action="j_security_check" method="POST">
       <input id="j_username" type="text" name="j_username" size="15" maxSize="30" />
       <br>
       <input type="hidden" name="j_uri" value="home.jsp"/>
       <br>
       <input type="password" id="j_password" name="j_password" size="15" maxSize="30" />
    </form>
    </body>
    </html>













     

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The difference between theory and practice is smaller in theory than in practice.”