0 Replies Latest reply on Oct 5, 2001 8:43 AM by parshuram

    Cache problems while compiling jsp

    parshuram

      Hi All,
      I am comming to contactdetails.jsp from two ways,either from add_party.jsp or Edit supplier.when i retrive the supplier list from Database(oracle) and want to display the details i am putting the object in session and getting it in contactdetails.jsp and showing it and i can't remove the value from the session as i may require the session value to edit another supplier.Untill this all works fine but when i use the contactdetails.jsp to adda new supplier and come to it the jsp it shows the last used session values and displays it on the screen which on the server dosen't show that it is executing the code where this session object is got from the session.
      i am attaching the code of the contactdetails.jsp please suggest some solution to this as i have tried out many things for this.


      <%@ page import = "users.SupplierList" %>
      <%@ page import = "users.DAO" %>
      <%@ page import = "users.Supplier" %>
      <%@ page import = "java.util.*;"%>
      <%@ page import = "users.Address"%>
      <%@ page import = "users.ContactPerson"%>
      <%@ page import = "users.AddressList"%>



      Add Supplier



      <%!
      //Supplier supp;
      String add,add1,city,pin,country,phone1,area_cd,fax,phone2,name1,desig1,cnt_no1,dept1,ext1,em_add1;
      String name2,name3,desig2,dept2,ext2,em_add2,desig3,cnt_no2,cnt_no3,dept3,ext3,em_add3;
      String srt_name,supp_name,pro_cat,supp_cat,inet_site,em_addr;
      String zone_code,ind_code,emp_code,accmgt_code;
      String saveflag,nextflag,editcontactflag,addcontactflag;
      //ContactPerson conPer;
      //Address address;
      int index,size,suppsize,counter,sizecon,max;
      String[] name,dept,desig,cnt_no,ext,em_add;
      //ArrayList conPerList;
      //String[] conarray;
      %>

      <%
      //this is saveflag, only name is saveconflag..
      if(request.getParameter("saveflag") != null)
      saveflag=request.getParameter("saveflag");
      System.out.println("saveflag is "+saveflag);

      if(saveflag!=null)
      {
      response.setHeader("Pragma","no-cache");
      }
      else
      {
      response.setHeader("Cache-Control","no-cache");
      //response.setDateHeader("Expires",0);
      }
      %>
      <meta http-equiv="Cache-Control" content="no-cache" />



      <!--
      function cleardata()
      {

      document.myform.reset();
      }

      function prevdata()
      {
      document.myform.action="SaveDetails.jsp?nextflag=\"N\"&prevflag=\"P\"";
      document.myform.submit()
      }

      function nextdata()
      {

      if(document.myform.ADD.value=="")
      {
      alert("Please enter Address");
      document.myform.ADD.focus();
      return ;
      }

      if(document.myform.CITY.value=="")
      {
      alert("Please enter City");
      document.myform.CITY.focus();
      return ;
      }

      if(document.myform.PIN.value=="")
      {
      alert("Please enter Pin");
      document.myform.PIN.focus();
      return ;
      }

      if(document.myform.COUNTRY.value=="")
      {
      alert("Please enter Country");
      document.myform.COUNTRY.focus();
      return ;
      }

      document.myform.action="SaveDetails.jsp?nextflag=\"N\"";
      document.myform.submit()
      }

      function savedata()
      {

      if(document.myform.ADD.value=="")
      {
      alert("Please enter Address");
      document.myform.ADD.focus();
      return ;
      }

      if(document.myform.CITY.value=="")
      {
      alert("Please enter City");
      document.myform.CITY.focus();
      return ;
      }

      if(document.myform.PIN.value=="")
      {
      alert("Please enter Pin");
      document.myform.PIN.focus();
      return ;
      }

      if(document.myform.COUNTRY.value=="")
      {
      alert("Please enter Country");
      document.myform.COUNTRY.focus();
      return ;
      }

      document.myform.action="SaveDetails.jsp?saveflag=\"S\"";
      document.myform.submit()
      }

      function editcontact()
      {

      if(document.myform.ADD.value=="")
      {
      alert("Please enter Address");
      document.myform.ADD.focus();
      return ;
      }

      if(document.myform.CITY.value=="")
      {
      alert("Please enter City");
      document.myform.CITY.focus();
      return ;
      }

      if(document.myform.PIN.value=="")
      {
      alert("Please enter Pin");
      document.myform.PIN.focus();
      return ;
      }

      if(document.myform.COUNTRY.value=="")
      {
      alert("Please enter Country");
      document.myform.COUNTRY.focus();
      return ;
      }

      document.myform.action="SaveDetails.jsp?editcontactflag=\"C\"";
      document.myform.submit()
      }

      function addcontact()
      {
      alert("calling addcontact");

      document.myform.action="Addcontact.jsp?addcontactflag=\"A\"";
      //window.open("http://gajanan:7001/jsp/Addcontact.jsp?addcontactflag=\"A\"&ADD=<%=add%>&ADD1=<%=add1%>&CITY=<%=city%>&PIN=<%=pin%>&COUNTRY=<%=country%>&AREA_CD=<%=area_cd%>&PHONE1=<%=phone1%>&PHONE2=<%=phone2%>&FAX=<%=fax%>&NAME1<%=name1%>&DESIG1=<%=desig1%>&CNT_NO1=<%=cnt_no1%>&DEPT1=<%=dept1%>&EXT1=<%=ext1%>&EM_ADD1=<%=em_add1%>");
      document.myform.submit();
      //window.close();
      }

      function editcontactdetails()
      {
      alert("calling editcontact");
      window.open("http://gajanan:7001/jsp/Addcontact.jsp?editcontactflag=\"EF\" ");
      window.close();
      }

      function numeric(thisobj)
      {
      //version = checkver()
      temp = thisobj.value
      if (temp.length != 0 && isNaN(temp))
      { alert("This Field should be numeric");
      //if (!version)
      thisobj.select() }
      }

      function Alpha(thisobj)
      {
      //version = checkver()
      temp = thisobj.value
      if (temp.length != 0 && !(isNaN(temp)))
      { alert("This Field should be Alphabetic");
      //if (!version)
      thisobj.select() }
      }

      function CheckMail(thisobj)
      {

      //Val = thisobj.name;

      // alert(Val);
      var mail=thisobj.value
      // alert(mail)
      //var mail=document.myform.EM_ADD1.value
      var goodEmail = mail.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
      if(goodEmail)
      {
      }
      else
      {
      alert("EMail Address is not Valid");
      //document.myform.EM_ADD1.focus();
      thisobj.focus();
      return;
      }

      }//end of CheckMail

      //-->



      <%
      //these are the changes made by Poonam.............
      /*DAO dao = new DAO();
      Vector addConVec = dao.getAddressContactList("S001");
      ArrayList addList = (ArrayList) v.get(0);
      Vector conVect = (Vector) v.get(1);

      for( int i = 0 ; i < addList.size() ; i++)
      {
      System.out.println( String.valueOf( addList.get(i) ) );
      ContactPersonList conList = (ContactPersonList)conVect.get(i);
      for ( int j = 0 ; j < conList.size() ; j++ )
      {
      System.out.println( String.valueOf( conList.get(j) ) );
      }
      }
      */
      %>

      <%
      if(request.getParameter("counter") != null)
      counter=Integer.parseInt(request.getParameter("counter"));
      System.out.println("Counter is "+counter);

      if(request.getParameter("count") != null)
      max=Integer.parseInt(request.getParameter("count"));
      System.out.println("Max is "+max);



      if(request.getParameter("nextflag") != null)
      nextflag=request.getParameter("nextflag");
      System.out.println("nextflag is "+nextflag);

      if(request.getParameter("INDEX") != null)
      index=Integer.parseInt(request.getParameter("INDEX").trim());
      System.out.println("Index is "+index);

      if(request.getParameter("editcontactflag") != null)
      editcontactflag= request.getParameter("editcontactflag");
      System.out.println("Flag to edit contact details is "+editcontactflag);

      if(request.getParameter("addcontactflag") != null)
      addcontactflag= request.getParameter("addcontactflag");
      System.out.println("Flag to add contact details is "+addcontactflag);


      //this block will execute only if saveflag comes null..
      if(!(saveflag!=null))
      {
      if (!(counter==0))
      {

      if(request.getParameter("NAME1") != null)
      name1= request.getParameter("NAME1");
      if(request.getParameter("DEPT1") != null)
      dept1= request.getParameter("DEPT1");
      if(request.getParameter("DESIG1") != null)
      desig1= request.getParameter("DESIG1");
      if(request.getParameter("CNT_NO1") != null)
      cnt_no1= request.getParameter("CNT_NO1");
      if(request.getParameter("EXT1") != null)
      ext1= request.getParameter("EXT1");
      if(request.getParameter("EM_ADD1") != null)
      em_add1= request.getParameter("EM_ADD1");
      System.out.println("Contact Name is "+name1);
      System.out.println("EMail id is "+em_add1);


      /*this value is got for adding contact person while editing
      contact details and value comes from addcontact jsp..*/

      //conPer =(ContactPerson)session.getValue("contactperson");
      //System.out.println("Contact list is "+conPer);
      ContactPerson conPer = new ContactPerson(name1,dept1,desig1,cnt_no1,ext1,em_add1);
      System.out.println("After conPer" +conPer);

      //this value is reqd for adding in address value..
      Address address = (Address)session.getValue("address");
      address.addContactPerson(conPer);
      System.out.println("After address");

      //this is trial
      //session.removeValue("address");
      size = address.contactPersonListsize();
      System.out.println("size of contact persons is"+size);

      System.out.println("Contact person list is "+conPer);

      name = new String[size];
      dept = new String[size];
      desig = new String[size];
      cnt_no = new String[size];
      ext = new String[size];
      em_add = new String[size];
      System.out.println("Designation is "+desig);
      System.out.println("Size of desig is "+desig.length);
      for(int i = 0; i<size; i++)
      {
      conPer = address.getContactPersonAt(i);
      name=conPer.getName();
      System.out.println("In for loop for size1"+name
      );

      dept=conPer.getDepartment();
      System.out.println("In for loop for size2"+dept
      );

      desig=conPer.getDesignation();
      System.out.println("In for loop for size3"+desig
      );

      cnt_no=conPer.getPhone();
      System.out.println("In for loop for size4"+cnt_no
      );

      ext=conPer.getPhoneExt();
      em_add
      =conPer.getEmail();
      }//end of for loop for size..

      //this is a trial..
      session.putValue("address",address);
      counter = 0;
      saveflag=null;
      }//end of if for counter...

      if (addcontactflag!=null)
      {
      if(request.getParameter("NAME1") != null)
      name1= request.getParameter("NAME1");
      if(request.getParameter("DEPT1") != null)
      dept1= request.getParameter("DEPT1");
      if(request.getParameter("DESIG1") != null)
      desig1= request.getParameter("DESIG1");
      if(request.getParameter("CNT_NO1") != null)
      cnt_no1= request.getParameter("CNT_NO1");
      if(request.getParameter("EXT1") != null)
      ext1= request.getParameter("EXT1");
      if(request.getParameter("EM_ADD1") != null)
      em_add1= request.getParameter("EM_ADD1");
      System.out.println("Contact Name1 is "+name1);
      System.out.println("EMail id1 is "+em_add1);

      if(request.getParameter("ADD") != null)
      add=request.getParameter("ADD");
      System.out.println("Address1 is "+add);

      if(request.getParameter("ADD1") != null)
      add1=request.getParameter("ADD1");

      if(request.getParameter("CITY") != null)
      city=request.getParameter("CITY");

      if(request.getParameter("COUNTRY") != null)
      country=request.getParameter("COUNTRY");

      if(request.getParameter("PIN") != null)
      pin=request.getParameter("PIN");


      if(request.getParameter("PHONE1") != null)
      phone1=request.getParameter("PHONE1");

      if(request.getParameter("PHONE2") != null)
      phone2=request.getParameter("PHONE2");

      if(request.getParameter("AREA_CD") != null)
      area_cd=request.getParameter("AREA_CD");

      if(request.getParameter("FAX") != null)
      fax=request.getParameter("FAX");

      ContactPerson conPer = new ContactPerson(name1,dept1,desig1,cnt_no1,ext1,em_add1);
      System.out.println("After conPer" +conPer);

      //address = new Address();
      //conPer = (ContactPerson)session.getValue("contact");
      Address address = (Address)session.getValue("addr");
      address.addContactPerson(conPer);
      System.out.println("After conPer Added" +conPer);
      size = address.contactPersonListsize();
      System.out.println("size of contact persons is"+size);

      name = new String[size];
      dept = new String[size];
      desig = new String[size];
      cnt_no = new String[size];
      ext = new String[size];
      em_add = new String[size];
      System.out.println("Designation is "+desig);
      System.out.println("Size of desig is "+desig.length);
      for(int i = 0; i<size; i++)
      {
      conPer = address.getContactPersonAt(i);
      System.out.println("After conPerson");
      name=conPer.getName();
      System.out.println("In for loop for size1"+name
      );

      dept=conPer.getDepartment();
      System.out.println("In for loop for size2"+dept
      );

      desig=conPer.getDesignation();
      System.out.println("In for loop for size3"+desig
      );

      cnt_no=conPer.getPhone();
      System.out.println("In for loop for size4"+cnt_no
      );

      ext=conPer.getPhoneExt();
      em_add
      =conPer.getEmail();
      }//end of for loop..

      //this value will be put only if there is any value in address wanted in session to add new address
      if(size!=0)
      {
      session.putValue("addr",address);
      }
      addcontactflag=null;
      }//end of if block for addcontactflag..

      if (editcontactflag!=null)
      {
      /*this value is got to get supplier values to display for editing wanted in session..*/
      Supplier supp =(Supplier) session.getValue("supp");

      suppsize = supp.addressListSize();
      System.out.println("Size of supplier list is"+suppsize);
      System.out.println("Supplier list is "+supp);
      Address address = new Address();

      if(!(suppsize == 0))
      {
      System.out.println("In suppsize ");

      if (nextflag!=null)
      {
      address = (Address)session.getValue("addfornext");
      System.out.println("Address list1 is "+address);
      }
      else
      {
      //this address is got for a specific supplier wanted in session not to remove..
      address = (Address)session.getValue("address");

      System.out.println("Address list2 is "+address);
      }
      add = address.getAddress1();
      add1= address.getAddress2();
      city= address.getCity();
      pin= address.getPin();
      country=address.getCountry();
      phone1=address.getPh1();
      area_cd=address.getPhAreaCode();
      fax=address.getFax();
      phone2=address.getPh2();

      }


      size = address.contactPersonListsize();
      System.out.println("size of contact persons is"+size);


      if(!(size == 0))
      {
      System.out.println("In size ");

      name = new String[size];
      dept = new String[size];
      desig = new String[size];
      cnt_no = new String[size];
      ext = new String[size];
      em_add = new String[size];
      System.out.println("Designation is "+desig);
      System.out.println("Size of desig is "+desig.length);
      for(int i = 0; i<size; i++)
      {
      ContactPerson conPer = address.getContactPersonAt(i);
      name=conPer.getName();
      System.out.println("In for loop for size1"+name
      );

      dept=conPer.getDepartment();
      System.out.println("In for loop for size2"+dept
      );

      desig=conPer.getDesignation();
      System.out.println("In for loop for size3"+desig
      );

      cnt_no=conPer.getPhone();
      System.out.println("In for loop for size4"+cnt_no
      );

      ext=conPer.getPhoneExt();
      em_add
      =conPer.getEmail();
      }//enf of for loop for size...
      }//end of if loop for size..

      System.out.println("After size ");

      /*add = address.getAddress1();
      add1= address.getAddress2();
      city= address.getCity();
      pin= address.getPin();
      country=address.getCountry();
      phone1=address.getPh1();
      area_cd=address.getPhAreaCode();
      fax=address.getFax();
      phone2=address.getPh2();
      name1=conPer.getName();
      dept1=conPer.getDepartment();
      desig1=conPer.getDesignation();

      cnt_no1=conPer.getPhone();

      ext1=conPer.getPhoneExt();
      em_add1=conPer.getEmail();

      System.out.println("Country is"+country);
      System.out.println("Pin code is" +pin);
      System.out.println("Address of contact person is "+add);

      */

      if(request.getParameter("SRT_NAME") != null)
      srt_name= request.getParameter("SRT_NAME");
      if(request.getParameter("SUPP_NAME") != null)
      supp_name= request.getParameter("SUPP_NAME");
      if(request.getParameter("PRO_CAT") != null)
      pro_cat= request.getParameter("PRO_CAT");
      if(request.getParameter("SUPP_CAT") != null)
      supp_cat= request.getParameter("SUPP_CAT");
      if(request.getParameter("EM_ADD") != null)
      em_addr= request.getParameter("EM_ADD");
      if(request.getParameter("INET_SITE") != null)
      inet_site= request.getParameter("INET_SITE");
      System.out.println("Short name is "+srt_name);
      System.out.println("URL id is "+inet_site);

      }//end of if for editcontactflag...
      }//end of if block for save flag..

      %>

      Address/Contact Persons Details
      <table border=1 width="80%" align="center" bgcolor="">



      Address

      <input type="text" maxlength=50 name="ADD" value="<%=add%>" size="25">


       

      <input type="text" maxlength=50 name="ADD1" value="<%=add1%>" size="20">

       
       



      City
      <input type="text" maxlength=15 name="CITY" value="<%=city%>" size="25" onBlur="Alpha(this);">

      Pin
      <input type="text" maxlength=15 name="PIN" value="<%=pin%>" size="20" onBlur="numeric(this);">

      Country
      <input type="text" maxlength=15 name="COUNTRY" value="<%=country%>" size="20" onBlur="Alpha(this);">


       
      Area Code
      Phone 1
      Phone 2
      Fax



      Phone
      <input type="text" maxlength=6 name="AREA_CD" value="<%=area_cd%>" size="25" onBlur="numeric(this);">

      <input type="text" maxlength=8 name="PHONE1" value="<%=phone1%>" size="10" onBlur="numeric(this);">
      <input type="text" maxlength=8 name="PHONE2" value="<%=phone2%>" size="10" onBlur="numeric(this);">
      <input type="text" maxlength=8 name="FAX" value="<%=fax%>" size="10" onBlur="numeric(this);">





      Contact Persons:

      <table border=1 width="80%" align="center" bgcolor="">

      Name
      Department

      Designation

      Phone
      Ext
      E Mail Address


      <%
      if(!(size == 0))
      {
      System.out.println("In if block"+size);
      for(int i = 0;i<size ;i++)
      {
      System.out.println("In for block"+size);
      %>

      <input type="text" maxlength=20 name="NAME<%=i%>" value="<%=name%>" size="20" onBlur="Alpha(this);">
      <input type="text" maxlength=20 name="DEPT<%=i%>" value="<%=dept
      %>" size="10">

      <input type="text" maxlength=20 name="DESIG<%=i%>" value="<%=desig%>" size="15" onBlur="Alpha(this);">
      <input type="text" maxlength=20 name="CNT_NO<%=i%>" value="<%=cnt_no
      %>" size="10" onBlur="numeric(this);">
      <input type="text" maxlength=20 name="EXT<%=i%>" value="<%=ext%>" size="7" onBlur="numeric(this);">
      <input type="text" maxlength=20 name="EM_ADD<%=i%>" value="<%=em_add
      %>" size="20" onChange="CheckMail(this);">


      <input type=hidden name=NAME<%=i%> value="<%=name%>">
      <input type=hidden name=DEPT<%=i%> value="<%=dept
      %>">
      <input type=hidden name=DESIG<%=i%> value="<%=desig%>">
      <input type=hidden name=CNT_NO<%=i%> value="<%=cnt_no
      %>">
      <input type=hidden name=EXT<%=i%> value="<%=ext%>">
      <input type=hidden name=EM_ADD<%=i%> value="<%=em_add
      %>">
      <%
      }
      }else{

      System.out.println("In else block of size");

      %>
      <!--
      <input type="text" maxlength=20 name="NAME1" value="<%=name1%>" size="20" onBlur="Alpha(this);">
      <input type="text" maxlength=20 name="DEPT1" value="<%=dept1%>" size="10">

      <input type="text" maxlength=20 name="DESIG1" value="<%=desig1%>" size="15" onBlur="Alpha(this);">
      <input type="text" maxlength=20 name="CNT_NO1" value="<%=cnt_no1%>" size="10" onBlur="numeric(this);">
      <input type="text" maxlength=20 name="EXT1" value="<%=ext1%>" size="7" onBlur="numeric(this);">
      <input type="text" maxlength=20 name="EM_ADD1" value="<%=em_add1%>" size="20" onChange="CheckMail(this);">


      -->
      <%


      }//end of else if size is zero...

      /*this block is integrated with size block,this sizecon is not reqd..*/
      /*if(!(sizecon == 0))
      {
      System.out.println("In if loop of sizecon");
      for(int i = 0;i<sizecon ;i++)
      {
      // System.out.println("In For loop");
      %>

      <input type="text" maxlength=20 name="NAME<%=i%>" value="<%=name%>" size="20" onBlur="Alpha(this);">
      <input type="text" maxlength=20 name="DEPT<%=i%>" value="<%=dept
      %>" size="10">

      <input type="text" maxlength=20 name="DESIG<%=i%>" value="<%=desig%>" size="15" onBlur="Alpha(this);">
      <input type="text" maxlength=20 name="CNT_NO<%=i%>" value="<%=cnt_no
      %>" size="10" onBlur="numeric(this);">
      <input type="text" maxlength=20 name="EXT<%=i%>" value="<%=ext%>" size="7" onBlur="numeric(this);">
      <input type="text" maxlength=20 name="EM_ADD<%=i%>" value="<%=em_add
      %>" size="20" onChange="CheckMail(this);">


      <%
      }//end of for loop for sizecon
      }//end of if loop for sizecon
      */
      %>



      <input type=hidden name=INDEX value="<%=index%>">
      <input type=hidden name=SRT_NAME value="<%=srt_name%>">
      <input type=hidden name=SUPP_NAME value="<%=supp_name%>">
      <input type=hidden name=PRO_CAT value="<%=pro_cat%>">
      <input type=hidden name=SUPP_CAT value="<%=supp_cat%>">
      <input type=hidden name=EM_ADD value="<%=em_addr%>">
      <input type=hidden name=INET_SITE value="<%=inet_site%>">

      <input type=hidden name=ADD value="<%=add%>">
      <input type=hidden name=ADD1 value="<%=add1%>">
      <input type=hidden name=CITY value="<%=city%>">
      <input type=hidden name=PIN value="<%=pin%>">
      <input type=hidden name=COUNTRY value="<%=country%>">
      <input type=hidden name=AREA_CD value="<%=area_cd%>">
      <input type=hidden name=PHONE1 value="<%=phone1%>">
      <input type=hidden name=PHONE2 value="<%=phone2%>">
      <input type=hidden name=FAX value="<%=fax%>">
      <input type=hidden name=NAME1 value="<%=name1%>">
      <input type=hidden name=DESIG1 value="<%=desig1%>">
      <input type=hidden name=DEPT1 value="<%=dept1%>">
      <input type=hidden name=CNT_NO1 value="<%=cnt_no1%>">
      <input type=hidden name=EXT1 value="<%=ext1%>">
      <input type=hidden name=EM_ADD1 value="<%=em_add1%>">
      <input type=hidden name=count value="<%=max%>">




      <%
      if (editcontactflag!=null)
      {
      %>
       
       
       
       

      <%

      }else{
      %>


       
       

      <%
      }
      editcontactflag=null;
      %>