Results 1 to 1 of 1
  1. #1
    paulsep is offline Member
    Join Date
    Jan 2011
    Posts
    1
    Rep Power
    0

    Default Beans in internet explorer not working (session)

    Hi,

    I have written an webshop where I am adding products to a basket, the products are saved in a session using java beans. When using Mozilla everything is working perfect. When in Internet exlorer a new session are started every time I go to a new page, when using Mozilla the numbers of sessions does not increase (used /manager/html) to view. Since I a new session are generated everytime I am clicking a link in IE, the session bean will therefore be emty.

    Server I am running this on is Tomcat 7.0.0
    JDK6.0_20
    Page http://www.mcpartner.no/webshop.jsp?gruppe_id=0&under=0
    On top of this page I am showing the session ID, in IE it is changing for every click and not in Mozilla.

    The site have been moved from an older Tomcat and JDK version when this problem started.

    Some code,

    When a client have choosen a product and click to place it in the basket, I am using a "help" page with the code below to place the product in the session.

    Java Code:
    <%@ page session="true" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
    <jsp:useBean id="kurv" scope="session" class="webshop.varer" />
    
    ---HTML CODE
    
    <jsp:setProperty name="kurv" property="farge" value="${param.farge}" />
    <jsp:setProperty name="kurv" property="vnr" value="${param.id}" />
    <jsp:setProperty name="kurv" property="antall" value="${param.antall}" />
      
    ----HTML CODE
    When the client have choosen all his products they can choose to go to the basket, the first thing I do is to check if I have an bean content higher than -1. If not a message are shown that the basket is empty, if higher I then start parsing the bean to get the information from the bean.


    Java Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
    
    <jsp:useBean id="kurv" scope="session" class="webshop.varer"/>
    
    
    <body>
    //Get the length of the bean
     <c:set var="antallet" value="<%=String.valueOf(kurv.getCount())%>" />      
    
    <c:choose>
    //Checking if the bean are emtpy
      <c:when test="${antallet == '-1'}">
         No product in the basket (comes up al the ways with IE and not Mozilla)
      </c:when>
      <c:otherwise>
        
         //counter to keep track on where in the bean I am
        <c:set var="teller" value="10"/>
        <c:if test="${antallet != '-1'}">    
    
         //make sure that I am starting at the beginning at the bean
        <jsp:setProperty name="kurv" property="teller" value="0" />
    
         //Looping thorugh the bean for each product selected
         <c:forEach varStatus="status" begin="0" end="${antallet}">
         <c:set var="temp" value="<%= String.valueOf(kurv.getAntall())%>" />
         <c:set var="vareVnr" value="<%= String.valueOf(kurv.getVnr())%>" />
         <jsp:getProperty name='kurv' property='farge' />
    
          //Increase the counter to get to the next bean element
         <c:set var="teller" value="${teller + 1}"/>
         </c:forEach>
         </c:if>
    </c:otherwise>
    </c:choose>
    </body>
    </html>

    varer.java:

    Java Code:
    package webshop;
    import java.io.*;
    import java.util.Vector;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    
    public class varer
    {
        private Vector antallet, farge, storrelse;
        private Vector vnr;
        private int teller, antall, antallTemp;
        private String test, vnrDenne, fargeDenne, storrelseDenne;
    
        public varer()
        {
            antall=0;
            antallet = new Vector();
            farge = new Vector();
            storrelse = new Vector();
            vnr = new Vector();
            test ="";
        }
    
        public void setVnrAdd(String vNummer)
        {
            boolean finnes=false;
            test="";
            int antall = 0;
            if( !vnr.isEmpty() )
            {
                int plassering = 0;
                for (int i = 0; i < vnr.size(); i++) {
                    if (vnr.elementAt(i).equals(vNummer)){
                        finnes = true;
                        plassering = i;
                        break;
                    }
                }//EOF for-loop
    
                    if (finnes ){
                        antall = Integer.parseInt((String)antallet.elementAt(plassering));
                        antall++;
                        antallet.setElementAt(String.valueOf(antall), plassering);
                        finnes = false;
                    }
                    else
                    {
                        this.vnr.addElement(vNummer);
                        this.antallet.addElement("1");
                        finnes = false;
                    }//EOF  if-else block
            }//EOF if(!vnr.isEmpty())
            else
            {
                this.vnr.addElement(vNummer);
                this.antallet.addElement("1");
            }
        }//EOF method setVnrAdd(...)
    
    
        public String getTest()
        {
            return test;
        }
    
        public String getVnr()
        {
            return (String)vnr.elementAt(teller);
        }
    
        public String getAntall()
        {
            return (String)antallet.elementAt(teller);
        }
    
        public String getFarge()
        {
            return (String)farge.elementAt(teller);
        }
    
        public String getStorrelse()
        {
            return (String)storrelse.elementAt(teller);
        }
    
        public int getCount()
        {
            if(vnr.isEmpty())
            {
                return -1;
            } else
            {
                return vnr.size() - 1;
            }
        }
    
        public void setVnr( String vnrDenne)
        {
            this.vnrDenne = vnrDenne;
        }
    
        public void setStorrelse( String storrelse)
        {
            this.storrelseDenne = storrelse;
        }
    
        public void setFarge( String farge)
        {
            this.fargeDenne = farge;
        }
    
        public void setAntall( String antallDenne )
        {
            int plassering = 0;
            boolean testVare = true;
            for (int i = 0; i < vnr.size(); i++) {
                if (vnr.elementAt(i).equals(vnrDenne)){
                    testVare = true;
                    plassering = i;
                    break;
                }
            }//EOF for-loop
    
            if(testVare)
            {
                this.vnr.addElement(vnrDenne);
                this.antallet.addElement(antallDenne);
                this.storrelse.addElement(storrelseDenne);
                this.farge.addElement(fargeDenne);
            }
            if(!testVare)
            {
                if (antallDenne.equals("0")) {
                    antallet.removeElementAt(plassering);
                    vnr.removeElementAt(plassering);
                    storrelse.removeElementAt(plassering);
                    farge.removeElementAt(plassering);
                } else
                    antallet.setElementAt(String.valueOf(antallDenne), plassering);
            }
        }//End of method setAntall
    
    
        public void setTeller(int teller)
        {
            this.teller = teller;
        }
    
        public String getTellerAdd()
        {
            teller++;
            return "";
        }
    
    }
    I will apperciate all help!
    Last edited by paulsep; 01-09-2011 at 06:31 PM.

Similar Threads

  1. Internet Explorer not update applet
    By billlin in forum New To Java
    Replies: 24
    Last Post: 07-18-2010, 12:45 AM
  2. Internet Explorer
    By maria.mt in forum New To Java
    Replies: 2
    Last Post: 04-17-2009, 05:10 AM
  3. Client Internet Explorer Setting
    By Mir in forum Networking
    Replies: 29
    Last Post: 06-26-2008, 12:01 PM
  4. Internet Explorer java version
    By shimer in forum Java Applets
    Replies: 2
    Last Post: 07-31-2007, 07:30 AM
  5. Problems with Internet Explorer and SSL Java
    By Peter in forum Advanced Java
    Replies: 2
    Last Post: 07-04-2007, 07:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •