在jsp里使用Cookie
写Cookie:
//从浏览器取得用户名
String username = request.getParameter("username");
//从浏览器取得密码
String password = request.getParameter("password");
//设置Cookie
Cookie userCookie = null;
Cookie passCookie = null;
//取得客户端的Cookie
//如果username和password满足条件则进入success.jsp
if ("admin".equals(username) && "1".equals(password)) {
userCookie = new Cookie("username", username);
passCookie = new Cookie("password", password);
userCookie.setMaxAge(20);
passCookie.setMaxAge(20);
response.addCookie(userCookie);
response.addCookie(passCookie);
response.sendRedirect("../success.jsp");
}
读Cookie:
String username = new String();
String password = new String();
//取得客户端的Cookie
Cookie[] cookies = request.getCookies();
//如果取得成功
if (cookies != null) {
相关文档:
<%
//header.jsp
out.println("Protocol: " + request.getProtocol() + "<br>");
out.println("Scheme: " + request.getScheme() + "<br>");
out.println("Server Name: " + request.getServerName() + "<br>" );
out.println(&quo ......
1、 在JSP文件上使用标签库
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
时出现问题,错误信息如下:
he absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar fil ......
JSP常用问答
收藏
< type="text/javascript">
document.body.oncopy = function() {
if (window.clipboardData) {
......
在jsp页面中将回车换行符存入表中方法
1.在一个textarea中输入一段文字,有换行时,将换行符一起插入数据库中
使用方法如下:
public static String TextToHtml(String sourcestr)
{   ......
一、JSP自定义标签简介
标签是一种XML元素,通过标签可以使JSP网页变得简洁并且易于维护,还可以方便地实现同一个JSP文件支持多种语言版本。由于标签是XML元素,所以它的名称和属性都是大小写敏感的
标准JSP标签是用来调用JavaBean组件的操作,处理定向请求以简化JSP页面开发与维护。JSP技术提供了一种封装其它动态类型 ......