Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7638471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:11:10+00:00 2026-05-31T08:11:10+00:00

document.location() function given in the logn.js code works fine in Internet Explorer but does

  • 0

document.location() function given in the logn.js code works fine in Internet Explorer but does not work in Firefox. The given js code is for implementing AJAX in the login page .. AJAX directs the code to a servlet which if login OK gives user Login as response.

logn.js

function logn(emailId,password) {
    var parameters="emailId="+emailId+"&password="+password;
    var xmlhttp;

    if (window.XMLHttpRequest) {    // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    } else {    // code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {     
            if(xmlhttp.responseText.toString()=="User Login") {     
                document.location("userhome.jsp"); 
            } else if(xmlhttp.responseText.toString()=="Admin Login") { 
                document.location("adminhome.jsp"); 
            }else {
                //document.getElementById("message").innerHTML = xmlhttp.responseText;
                alert(xmlhttp.responseText);
            }       
        }
    };

    xmlhttp.open("POST", "LoginServlet", true);
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp.send(parameters);   
}

the following is the servlet code LoginServlet.java

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PrintWriter out=response.getWriter();
        String emailId=request.getParameter("emailId");
        String password=request.getParameter("password");



        if (emailId.isEmpty()||password.isEmpty()) { 
            out.write("Please enter EmailId/Password");
        } else {
            LoginModel lm=new LoginModel();
            lm.setEmailId(emailId);
            lm.setPassword(password);

            LoginService ls=new LoginService();
            lm=(LoginModel) ls.loginCheck(lm);

            if(lm!=null){
                System.out.println("login ok");
                HttpSession session =request.getSession();
                System.out.println(lm.getLoginId());
                session.setAttribute("userlogin", lm);

                if (lm.getIsAdmin()==0) {
                    System.out.println("aaaaaaaaaaa");
                    out.write("User Login");
                }
                else if (lm.getIsAdmin()==1) 
                    out.write("Admin Login");

                ls.setIsActive(lm.getLoginId(),1);
            } else 
                out.write("Wrong EmailId/Password");
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:11:11+00:00Added an answer on May 31, 2026 at 8:11 am

    You should be using:

    window.location = "userhome.jsp";
    

    and

    window.location = "adminhome.jsp";
    

    There were a couple issues with how you were doing it. It’s preferred to use window.location instead of document.location. And, you assign to it, not call it like a function.

    MDN reference: https://developer.mozilla.org/en/DOM/window.location

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$(document).ready(function(){ $(a[href*='http://']:not([href*='+location.hostname+'])).attr(target,_blank); $(a[target!='_blank'][target!='_top']).click(function(){ $(#actualcontent).load($(this).attr(href)); window.location.hash=$(this).attr(href); return false; }); }); So I have this code
I'm using the following code.. $(document).ready(function(){ $(#test a).click(function(){ var labelTo = $(this).text(); window.location =
The Django jQuery fix which is given here does not work on iPad. Any
Following code works ok, except that it not zoom to the given points. If
Appreciate some insight given the following code: <script type=text/javascript> $(document).ready(function() { var soapEnv =
I have the following code but the FB.login gives a FB is not defined
$(document).ready(function () { $(#tree).treeview({ collapsed: true, animated: fast, control: #tree, persist: location, prerendered: false
I have a show function that returns a form, given a document id. The
What is the difference between document.location.href and document.location ? Is it the same across
I know that in Javascript document.location.href = #my_id tells the browser to display the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.