2005-11-25

JSP安全编程实例浅析

来源: 本站收集整理 作者:佚名 评论 0 条
 

public void addFriend(int i, String s, String s1)
throws DBConnectException
{
 try
 {
  if……
  else
  {
   DBConnect dbconnect = new DBConnect("insert into friend (authorid,friendname) values (?,?)");
   dbconnect.setInt(1, i);
   dbconnect.setString(2, s);
   dbconnect.executeUpdate();
   dbconnect.close();
   dbconnect = null;
  }
 }
 catch(Exception exception)
 {
  throw new DBConnectException(exception.getMessage());
 }
}

  下面是调用:

friendName=ParameterUtils.getString(request,"friendname");
if(action.equals("adduser")) {
 forumFriend.addFriend(Integer.parseInt(cookieID),friendName,cookieName);
 errorInfo=forumFriend.getErrorInfo();
}

  假如采用的是实例变量,那么该实例变量属于该实例的所有线程共享,就有可能出现用户A传递了某个参数后他的线程转为睡眠状态,而参数被用户B无意间修改,造成好友错配的现象。


共4页: 上一页 [1] [2] [3] 4 下一页
(本文仅表明作者个人观点,不代表本站及其管理员立场.) 推荐 收藏 投稿 打印 返回 关闭
上一篇:叩开C#之门系列之C#与面向对象编程语言  
下一篇:JSP/Servlet的重定向技术综述
    评论加载中…
 推荐文章
     

网站首页  -  网站地图 -   站长论坛  -  网站投稿  -    -  网站管理
Copyright © 2008 芜湖站长站 All Rights Reserved 皖ICP备07500611号