• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Browser calls servlet twice (iE)

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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();
}
}
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, I did the same thing once.
I had something like this:

(Note that the on_Click is a deliberate typo..._
Dave
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
would this be fixed by having the method return false? as you might tell, javascript is not my thing.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic