Jsp中的Cookie对象
Cookie对象是由Web服务器产生后保存在浏览器中的信息,它可以用来保存一些小量的信息在浏览器中;该对象不属于Jsp的内置对象,它需要构造才能使用
1. 构造:
Cookie cookie对象名=new Cookie(cookie变量名,cookie中所存储的对象)
2. cookie的写入与读取
写入:response.addCookie(cookie对象名);
读取:request.getCookies(); //它返回的是一个Cookie数组
3.Cookie对象常用的方法
getName():获取当前cookie对象中的cookie变量名
getValue():获取当前cookie对象中所存储的值
setMaxAge(int time):设置cookie对象的存货时间,time为指定的秒数
相关文档:
在JSP和Servlet中有几个地方都可以设置编码,各个编码的功能也不一样,本文将对各个编码做一个小结。
各种编码一览
A. JSP/Servlet都有的编码设置
1. request.setCharacterEncoding("UTF-8")
2. response.setCharacterEncoding("UTF-8")
3. response.setContentType("text/html;
charset=U ......
struts2的实现方法
LangSelector.jsp
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<script type="text/javascript">
<!--
function langSelecter_onChanged() {
& ......
格式如下: <%!
[synchronized] 返回类型 函数名(形参列表)
&nbs ......
1. jsp:forward标签只能实现本网站内的跳转,即浏览器上显示的依然是之前客户端的页面文件名,而不是跳转后的页面文件名
而response.sendRedirect()可以跳转到任何一个地址的页面,且浏览器上显示的是跳转后的页面文件名
2. 当在之前的客户端页面文件中使用response.setAttribute()存储了某个值后,使 ......
有的时候会忘记,记录一下:
<iframe id="xx" name="xx" width="515" height="177" scrolling="no" border="0" marginwidth="0" marginheight="0" frameborder="0" src="Xx.jsp"></iframe>
要使jsp不变形,主要是marginwidth="0" marginheight="0"两个属性。 ......