Hello there.... I am having strange results when I call a servlet. When I call the servlet with Netscape(4.77) Everything seems to be working fine. When I call the servlet with IE(6.0.26) It calls the servlet twice. Here is the code of my servlet: Do get and do post simply call this method. public void checkInfo(javax.servlet.http.HttpServletRequest request, javax.servlet.http. HttpServletResponse response) throws javax. servlet.ServletException, java.io.IOException { HttpSession session = request.getSession(true); try { if (session.isNew()) { id = request.getParameter("id"); session.setAttribute("userID", id); db.setId(id); pass = request.getParameter("pass"); db.setPass(pass); getServletContext().setAttribute("conPool", ds); db.setDs(ds); rs = db.checkLogon(); Calendar calendar = Calendar.getInstance(); String months[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }; int day = calendar.get(Calendar.DATE); String month = (months[calendar.get(Calendar.MONTH)]); int year = calendar.get(Calendar.YEAR); String theDate = month + "/" + day + "/" + year; if (rs.next()) { userVec.addElement(rs.getString(1)); System.out.println("added 1"); userVec.addElement(rs.getString(2)); System.out.println("added 2"); userVec.addElement(rs.getString(3)); System.out.println("added 3"); userVec.addElement(rs.getString(4)); System.out.println("added 4"); userVec.addElement(rs.getString(5)); System.out.println("added 5"); userVec.addElement(rs.getString(6)); System.out.println("added 6"); userVec.addElement(theDate); System.out.println("added date"); session.setAttribute("userData", userVec); rs.close(); } else { response.sendRedirect("incorrect_info.html"); session.invalidate(); } } if (!(userVec.isEmpty())) { sessionVector = (Vector) session.getAttribute("userData"); role = (String) sessionVector.elementAt(2); int i; for (i = 0; i < sessionVector.size(); i++) { System.out.println("Vector item " + i + ":" + " is: " + sessionVector.elementAt(i)); } if (role.equals("a")) { getServletContext().getRequestDispatcher( "/mainMenu.jsp").forward(request, response); } else if (role.equals("u")) { getServletContext().getRequestDispatcher( "/mainMenuAP.jsp").forward(request, response); } } } catch (Exception e) { e.printStackTrace(); } }
Dave Vick
Ranch Hand
Joined: May 10, 2001
Posts: 3244
posted
0
Rich What does the code on the calling page look like? Do you have any javascript that is maybe submitting it and also through a submit button?
would this be fixed by having the method return false? as you might tell, javascript is not my thing.
Eric Lim
Greenhorn
Joined: Apr 01, 2002
Posts: 19
posted
0
Rich I have encountered similar problem as well. In my case, I have isolated the problem only to a GET request. It doesn't happen in a POST, not even in IE. I'm not sure if we have the same situation but I hope this helps. Eric