Here's an article about JavaScript invoking servlet
that you may be interested in.

http://www-106.ibm.com/developerworks/library/wa-resc/?dwzone=web

regards,
-Joe

-----Original Message-----
From: Michael Weller [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 18, 2003 4:18 AM
To: [EMAIL PROTECTED]
Subject: Re: Calling server side via javascript


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

___________________________________________________________________________
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

Reply via email to