关于jsp中的cookie小程序
<body>
<%
Cookie[] cookies = request.getCookies() ;
Cookie cookie = null ;
if(cookies!=null){
cookie = cookies[0] ;
out.print("上次访问的ip是: " + request.getRemoteAddr() +"<br>") ; //得到客户端的ip
out.print("上次访问时间:" + cookie.getValue()) ;
cookie.setValue(new java.util.Date().toString()) ;
response.addCookie(cookie) ; //保存到客户端
cookie.setMaxAge(365 * 24 * 3600);
}
if(cookies==null){
cookie = new Cookie("AccessTime","") ;
cookie.setValue(new java.util.Date().toString()) ;
response.addCookie(cookie) ; //保存到客户端
cookie.setMaxAge(365 * 24 * 3600);
}
%>
</body>
ps:如果没有设置cookie的有效期,那么在关闭浏览器时cookie会被删除。如果生命期为负整数,表示这个cookie对象是临时的,不要保存在硬盘中,关闭浏览器后数据会自动丢失!
相关文档:
(一)包含其他页面的方法:
include指令:<%@ include file = "test1.jsp" %>
静态包含,可以包含任意格式的文件(不光是jsp文件,还可以是txt等文本文件),静态包含就是将被包含文件的内容拷贝到包含文件中,进行执行。当前页面和test1.jsp中不能有重名的变量。
include动作 <jsp:include page = "tes ......
(转载标签:fckeditorit 分类:Java)
1.将FCKeditor目录下的editor拷贝到项目的WebContent目录下
2.并把ECKeditor-2.3.jar 和 commons-fileupload.jar拷贝到项目\WebContent\WEB-INF\lib目录下
3.把 FCKeditor.tld拷贝到项目\WebContent\WEB-INF下
4.在web.xml里添加如下代码
代码
<servlet> ......
1. 怎么在多个JSP页面之间进行参数传递?需要使用JSP的内置作用域对象session。利用它的两个方法setAttribute(),getAttribute()
2. 下面的这个实例实现了把第一个JSP页面的参数传递给第三个页面的功能
3. &nbs ......
get
jsp url ${param.serialID}
action jsp String commentId = ServletActionContext.getRequest().getParameter("commentId");
-- ......
<%@page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="ccp.suddenattack.service.news.*"%>
......