String action = (String)request.getParameter("action") ;
  if ( action != null && action.equals("userlogin") ) 
  {
      String timeZone  = (String)request.getParameter("timeZone") ;
      String userName  = (String)request.getParameter("userName") ;      Cookie cookie2=new Cookie("USERNAME", userName);
      Cookie cookie3=new Cookie("TIMEZONE", timeZone);
      cookie2.setMaxAge(365*24*60*60);
      cookie3.setMaxAge(365*24*60*60);
      response.addCookie(cookie2);
      response.addCookie(cookie3);      Connection conn = MyDB.getConnection();
      session.setAttribute("THE_PARTNERNO","11");
  session.setAttribute("THE_TIMEZONE",timeZone);
  
  int  partnerNo = 11 ;
  session.setAttribute("THE_FUNCAREA","COMPANY");   
      String password = (String)request.getParameter("userPassword");   String sql = "select u.user_no,p.password  from users u,user_passwd p where u.loginName='"+MyDB.toSQLStr(userName)+"' and u.partner_no="+ partnerNo+
         " and p.user_no=u.user_no" ;
      String[][] data = MyDB.fetchStrData(conn,sql) ;
      if ( data ==null || !data[0][1].equals(password) )
      {
           out.println("<script>alert('用户不存在或者口令不对');parent.document.form0.userName.focus();</script>");
           return;
      }
      int userNo = Integer.parseInt(data[0][0]) ;      String helpedName = (String)request.getParameter("helpedName");
      if (helpedName != null && helpedName.trim().length() != 0 ) 
      {
          sql = "select user_no from users where loginName='"+MyDB.toSQLStr(helpedName)+"' and partner_no='"+ partnerNo+"'" ;
  data = MyDB.fetchStrData(conn, sql );
          if( data == null)
          {
              out.println("<script>alert('该被帮助者不存在');parent.document.form0.helpedName.focus();</script>");
              return;
          }
          int helpedNo = Integer.parseInt(data[0][0]) ;
          sql = "select func_no from helper_right where user_no="+helpedNo +" and helpedby="+userNo +" and expireDate >= getDate()" ;
          data = MyDB.fetchStrData(conn,sql );
          if ( data == null  )
          {
            out.println("<script>alert('你无权帮助"+helpedName+"');parent.document.form0.helpedName.focus();</script>");
            return;
          }
          session.setAttribute("THE_USERNO",""+helpedNo );               
          session.setAttribute("THE_HELPEDBY",""+userNo);    
  }
  else
      {
         sql = "select func_no from rights where user_no="+userNo  ;
         data = MyDB.fetchStrData(conn,sql );
     if ( data == null )
     {
          //  out.println("<script>alert('你无权访问系统');parent.document.form0.userName.focus();</script>");
          //  return;
         }
         session.setAttribute("THE_USERNO",""+userNo ); 
         session.setAttribute("THE_HELPEDBY",null);    
      }
      
  if ( data == null )  session.setAttribute("THE_RIGHTS",null );     
      else
  {
  int rows = data.length;
          int[] rights = new int[rows];
          for(int i = 0 ;i < rows ; ++ i)
          {
             rights[i] = Integer.parseInt(data[i][0]);
       }
      session.setAttribute("THE_RIGHTS",rights);     
      }      String uri = "/netoffice/main.jsp" ;
      out.println("<script>parent.document.form0.action.value='';parent.location='" + uri+"';</script>");
  return ;
   }
   java.util.GregorianCalendar toDay = new java.util.GregorianCalendar();
   int sYEAR  = toDay.get(toDay.YEAR);
   int sMonth = toDay.get(toDay.MONTH)+1; 
   int sDay = toDay.get(toDay.DATE); 
   int hour = toDay.get(toDay.HOUR); 
   int MINUTE = toDay.get(toDay.MINUTE);
   int AM_PM = toDay.get(toDay.AM_PM);
   if (AM_PM >=1) hour = hour + 12;  
   String today = sYEAR+"年"+sMonth+"月"+sDay+"日"+hour+"时"+MINUTE+"分";    String userName="",timeZone="8" ;
   Cookie cookies[]=request.getCookies();
   int j = (cookies==null )?0:cookies.length ;
   for ( int i = 0 ; i < j ;i++ )
   {
     if ( cookies[i].getName().equals("USERNAME") ) 
        userName = cookies[i].getValue();
     else if ( cookies[i].getName().equals("TIMEZONE") ) 
        timeZone = cookies[i].getValue();
   }

解决方案 »

  1.   

    在本页定义一个隐藏域refrenceTimes
    <input type="hidden" value="<%=refrenceTimes%>">用如下代码来判断次数:String refrenceTimes = request.getParameter("refrenceTimes");
    if(refrenceTimes == null)
    {
      refrenceTimes = "1";
    }
    else
    {
      refrenceTimes = Integer.toString(Integer.parseInt(refrenceTimes))+ 1);
    }采用本页提交给本页可以知道被引用的次数。如果要看本页面被其他页面引用的次数,可采用类似的做法。只要引用一次,改变一次该参数就行了。