websphere6.0 cookies 文件失效
websphere6.0 cookies 文件 为啥存不进本地磁盘 --------------------编程问答-------------------- --------------------编程问答-------------------- 小子,别作广告,我是来解决问题的。SB --------------------编程问答-------------------- 我在应用服务器层的会话管理中设了启用cookies,超时3600秒。在web应用的会话管理中设了启用cookies,超时3600秒。
就是不见cookies文件生成。
我的WebSphere版本是
IBM WebSphere Application Server - Express, 6.0.0.1
构建号: o0445.08
构建日期: 11/10/04
阿敏总司令帮忙啊!!! --------------------编程问答-------------------- 你自己的cookie程序怎么写的呢?
在浏览器端用HttpWatch或FireBug监控一下吧。
另外浏览器的Cookie是不是被禁止掉了。 --------------------编程问答-------------------- 客户端cookies当然不会禁掉。
代码如下:
public void performTask(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
Cookie[] cookies=request.getCookies();
if(cookies!=null){
for(int i=0;i<cookies.length;i++){
System.out.println("cookies is==========="+cookies[i].getName());
System.out.println("cookies is==========="+cookies[i].getValue());
}
}
int cookiemonth = 6*24*60*60;
String immoflag = request.getParameter("immoflag");
String userName = request.getParameter("user_name");
String password = request.getParameter("user_password");
HttpSession sess = request.getSession();
if(cookies[0].getValue().equals(sess.getId())){
System.out.println("the same session");
}
Cookie cookieusername =new Cookie("user_name",userName);
cookieusername.setPath("/uaes/");
cookieusername.setMaxAge(cookiemonth);
Cookie cookiepassword =new Cookie("user_password",password);
cookiepassword.setPath("/uaes/");
cookiepassword.setMaxAge(cookiemonth);
Cookie cookieimmoflag =new Cookie("immoflag",immoflag);
cookieimmoflag.setPath("/uaes/");
cookieimmoflag.setMaxAge(cookiemonth);
response.addCookie(cookieusername);
response.addCookie(cookiepassword);
response.addCookie(cookieimmoflag);
String domain = request.getParameter("domain");
String jump_url = request.getParameter("jump_url");
String authtype = request.getParameter("authtype");
sess.setAttribute("user_password", password);
sess.setAttribute("username", userName);
Connection jdbcConnection = DatabaseUtil.getConnection();
if (jdbcConnection == null) {
System.err.println("Can not get jdbc connection, please check your database or config.");
log
.fatal("Can not get jdbc connection, please check your database or config.");
return;
}
try {
Statement stmt = jdbcConnection.createStatement();
String sql = "";
if("IMMO".equals(immoflag)){
sql = "select * from sys_user where immoflag='"+immoflag+"' and logon_id='"
+ userName + "'";
}else{
sql = "select * from sys_user where logon_id='"
+ userName + "'";
}
System.out.println("SQL="+sql+"cdccccccccccccccccc");
ResultSet rs = stmt
.executeQuery(sql);
if (rs.next()){
sess.setAttribute("KHUserID", rs.getString("user_pk"));
sess.setAttribute("UserNameChn", rs.getString("name_chn"));
sess.setAttribute("UserNameEng", rs.getString("name_eng"));
sess.setAttribute("UserNameLogon", rs.getString("logon_id"));
sess.setAttribute("Level", rs.getString("level"));
sess.setAttribute("IMMOFLAG", immoflag);
sess.setAttribute("ISIMMOFLAG",rs.getString("IMMOFLAG"));
String role = rs.getString("role_list");
rs.close();
if (role == null || role.trim().length() == 0) {
throw new Exception("the role of user has not been set.");
} else {
if (role.endsWith(","))
role = role + "0";
String powerCode = "0";
String roleSelectSql = "select * from sys_role where rl_valid='Y' ";
if(!role.equals("*"))
roleSelectSql += " and role_pk in ("
+ role + ") ";
rs = stmt.executeQuery(roleSelectSql);
String roleStr="";
while (rs.next()) {
roleStr=roleStr+"|"+rs.getString("RL_NAME");
powerCode = PowerBitUtil.bitAdd(powerCode, rs
.getString("RL_CODE"));
}
roleStr=roleStr.substring(1, roleStr.length());
sess.setAttribute("Role", roleStr);
sess.setAttribute("PowerCode", powerCode);
rs.close();
stmt.close();
jdbcConnection.close();
}
} else {
throw new Exception("user/password not correct");
}
} catch (Exception e) {
System.err.println("user[" + userName + "] failed to logon."
+ e.getMessage());
log.error("user[" + userName + "] failed to logon."
+ e.getMessage());
request.getRequestDispatcher("/uestor/login_failed.jsp").forward(
request, response);
}
} --------------------编程问答-------------------- cookieusername.setPath("/");
或
cookieusername.setPath("/uaes");
看看。 --------------------编程问答-------------------- 司令一出马就是不一般 --------------------编程问答-------------------- 问题解决了吗?怎么解决的Share一下呀。 --------------------编程问答-------------------- path设成 /uaes 也不行
可能websphere中漏配什么了吧? --------------------编程问答-------------------- IBM WebSphere Application Server - Express, 6.0.0.1
没在这上面弄过,你尝试一下升级到最新版,然后再试一下吧,最好用FireBug或HttpWatch进行监控一下。
另外将浏览器禁止掉Cookie功能,或者打开为提示接收Cookie再观察一下。
补充:企业软件 , WebSphere