Re: Calling server side via javascript

Michael Weller <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <007701c2d747$e3676850$3807b9d9@gutschimachine>
Hi!
You can "use" just the same script with JSP/servlet as well (since you're
not using ActiveX in your JSP/servlet, your JSP/servlet is just printing
HTML code that makes the client use it). But you'd have an IE-only site
because only IE understands that ActiveX stuff.
If you really don't want a page reload, use one of the scripts at [1] and
parse the request on the client side. I'd not recommend that though (what's
wrong with a page reload? The user expects that to happen and why bother?)

HTH!

-mw

[1] http://dcljs.de/faq/howto.php?in=misc#textdatei - sorry couldn't find an
English version

----- Original Message -----
From: Bhushan Bhangale
To: [email protected]
Sent: Tuesday, February 18, 2003 8:13 AM
Subject: Calling server side via javascript


I was just browsing on one site and saw this javascript fucntion. There is a
login screen and when I click on Submit button it calls this fuction and
process the request. This prevents refreshing of page. If I build that page
in jsp instead of asp then how it will work. Any idea. The following
function uses ActiveXObject which I guess we can't use in jsp or servlets.

function LoginUser() {
    window.status ="Processing..."
    var oXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP")
    oXMLHTTP.open("get", "app/include/login.asp?paramLoginID=" +
form1.txtLoginID.value , false, form1.txtLoginID.value,
form1.txtPassword.value);
    oXMLHTTP.send("xmlDoc");
   //alert(oXMLHTTP.responseText)

    if (oXMLHTTP.responseText.search("ErrorChangePassword") > 0  ){
        alert("Please " +form1.txtLoginID.value +" change your password")
   // return true
    }


    if (oXMLHTTP.responseText.search("Error:") >= 0) {
        alert(oXMLHTTP.responseText);
        window.status ="Done"
        return false
    }
    if(oXMLHTTP.responseText.search("You are not authorized to") > 0 ) {
        alert("Invalid UserID / Password combination.\n\nPlease re-enter.");
        window.status ="Done"
        return false
    }
    //alert(oXMLHTTP.responseText.search("Error:"))
    //alert(GetCookie("DefaultPage"));
   document.location = "app/default.asp"
   window.status ="Done"
   return true
 }

Regards
Bhushan

___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.