th="false" sslProtocol="TLS" keystoreFile="/conf/.keystore" ????? keystorePass="198277"/> d.测试为: https://localhost:8443 e.在自己的程序中添加ssl认证方式为: 在web.xml 中添加
Success / GET POST
CONFIDENTIAL
f.用上提为例就是 修改web.xml 为 ??? xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ??? xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" ??? version="2.4">
?MySQL Test App
Success / GET POST
CONFIDENTIAL
? ????? DB Connection ????? jdbc/TestDB ????? javax.sql.DataSource ????? Container ?
访问: https://localhost:8443/DBTest/test.jsp
g.如果与2配置的jdbcRealm结合起来进行表单认证 先在user_roles表中添加user_name:ycg role_name:web-user 在users表中添加user_name:ycg user_pass:198277
然后在web.xml中添加
web-user
?BASIC ?My Member Area
修改后的web.xml如: ??? xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ??? xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" ??? version="2.4">
?MySQL Test App
Success / GET POST
web-user
CONFIDENTIAL
?BASIC ?My Member Area
? ? ????? DB Connection ????? jdbc/TestDB ????? javax.sql.DataSource ????? Container ?
测试: http://localhost:8080/DBTest/test.jsp 将通过ssl连接,并进行表单认证.用户密码可在user_roles,和users中添加.
5.中文乱码问题: mysql 默认编码 iso tomcat request 传输编码 iso 如果要显示中文 在*.jsp中添加
<%@ page language="java" contentType="text/html; charset=GB18030" pageEncoding="GB18030" %>
如果是数据传输中的乱码(如用servlet从mysql数据库读出的数据) 用以下两个转码函数转码,如果不清楚由哪种编码转成哪种编码,就多尝试. ?//转码GBK转ISO ?public String toISO(String input) { ??try { ????byte[] bytes = input.getBytes("GBK"); ????return new String(bytes,"ISO8859-1"); ??}catch(Exception ex) { ??} ??return input;
?} ? ?//转码IS0转GBK ?public String toGBK(String input) { ??try { ???byte[] bytes = input.getBytes("ISO8859-1"); ???return new String(bytes,"GBK"); ??}catch(Exception ex) { ??} ??return input; ?}
例如: 当你发现你在mysql中想搜索中文是遇到编码问题时使用: String sql = "select sum(number) from studentTable where grade="+toISO("大三"); 当你从mysql数据库中读出的数据送到jsp显示为乱码时 rs = st.executeQuery(...); studentBean.setStudentName(toGBK(rs.getString("studentName")));
以上配置都测试成功.主要参考tomcat5.0的帮助文档.其中如有错误的认识,还望不吝赐教.
上一页 [1] [2] [Delphi程序]Delphi组件indy 10中IdTCPServer修正及SSL使用心得 [MySql]tomcat 5.X 的mysql DBCP配置指南及相关问题小结
|