jsp几种方法
1.必须继承自HttpServlet
2.必须实现doGet()或者doPost()
3.必须在web.xml中配置Servlet
<servlet>
<servlet-name> </servlet-name>
<servlet-class> </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> </servlet-name>
<url-pattern> </url-pattern>
</servelt-mapping>
HttpServeltRrequest:请求对象
getParameter():获得表单元素的值
getAttribute():获得request范围中的属性值
setAttribute():设置reqeust范围中的属性值
setCharacterEncoding():设置字符编码
HttpSerletResponse:相应对象
sendRedirect():外部跳转
getWriter():获得输出流对象
setContentType("text/html; charset=utf-8"):设置相应内容格式和编码
四种会话跟踪方式:
1.Session
HttpSession session = request.getSession();
session.setAttribute("name", "zhangsan");
session.setAttribute("pwd", "aaa");
String name = (String) session.getAttribute("name");
2.cookie:
//创建Cookie
Cookie cookie = new Cookie("name", "zhangsan");
//设置Cookie的超时时间
cookie.setMaxAge(24 * 60 * 60 *60);
//把Cookie发送到客户端
response.addCookie(cookie);
//得到客户端发送的Cookie
Cookie [] cookies = request.getCookies();
for(int i=0; i <cookies.length; i++) {
Cookie temp = cookies[i];
String key = temp.getName();
String value = temp.getValue();
}
3.隐藏表单域
<input type="hidden" name="name" value="zhangsan" />
request.getParameter("name");
4.Url重写
问号传参
LoginServlet?username=zhangsan&pwd=123
String name = request.getParameter("username");
相关文档:
这个问题是从项目中设计数据库和操作数据库的人不同而造成的。所用的数据库
是sybase,设计时把数据类型设计为nvarchar了,如果是中文,读取出来就会得
到乱码。我试了好多方法还是不行,最后无奈,只好将数据类型改为varchar了。
所以在此总结一下中文乱码问题。
一、JSP与页面参数之间的乱码
&nb ......
FCKeditor jsp 配置 使用
2009-04-07 16:57
FCKeditor是一款跨平台的在线编辑器,到我发布本文,FCKeditor的官方版本已经发展到了2.6.4
点击进入 官网
1、首先登陆www.fckeditor.net/download下载FCKeditor的最新版本,需要下载2个压缩包,一个是基本应用,另一个是在为在jsp下所准备的配置。
  ......
因为是跟着视频学习的,有很多用的东西不一样,但是还是慢慢的摸索出来啦!
1.Microsoft JDBC Driver 的下载安装
只要在网上找到资源一步步来就可以了。
2.配置环境变量
我用的是tomcat6.0首先配的是
classpath和path,这些都是在配jdk的时候就配过了,所以就不详细说明了,只要将lib和bin文件加入到相关 ......
方法一、
login.html
<html>
<head>
<title>用户登录</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
</head>
<script language="javascript">
&nbs ......
第一种:
就是直接给出下载的地址,这种方式很不好,因为会暴露你的地址,带来很多不安全的因素,可以说是千万不要用这种
第二种:
下载页面
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<html>
<head>
<title>download</title>
</head>
< ......