易截截图软件、单文件、免安装、纯绿色、仅160KB

JSP实例一、购物车


知识准备:
JDBC访问数据库的基本步骤
(1)、将数据库的JDBC驱动加载到工程类库中。
(2)、加载JDBC驱动,并将其注册到DriverManager中。下面是一些主流数据库的JDBC驱动加载注册码:
①、oracle数据库
Class.forName(“oracle.jdbc.driver.OracleDriver”).newInstance();
②、Sql Server 7.0/2000数据库
Class.forName(“com.microsoft.jdbc.sqlserver.SQLServerDriver”).newInstance();
③、MySQL数据库
Class.forName(“com.mysql.jdbc.Driver”).newInstance();
(3)、建立数据库连接,取得Connection对象。
①、oracle数据库
String url=”jdbc:oracle:thin:@localhost:1521:orcl”;
String user=”scott”:
String password=”tiger”;
Connetion conn=DriverManager.getConnetion(url,user,password);
②、Sql Server 7.0/2000数据库
String url=”jdbc:microsoft:sqlserver://localhost:1443;DatabaseName=pubs”;
String user=”sa”;
String password=””;
Connection conn=DriverManager.getConnection(url,user,password);
③、MySQL数据库
String url=”jdbc:mysql://localhost:3306/testDB?user=root&password=root&
useUnicode=true&charaterEncoding=gb2312”;
Connection conn=DriverManager.getConnection(url);
(4)、建立Statement对象或PreparedStatement对象。
//建立Statement对象
Statement stmt=conn.createStatement();
//建立PreparedStatement对象
String sql=”select *from users where userName=? And password=?”;
PreparedStatement pstmt=conn.prepareStatement(sql);
pstmt.setString(1,”admin”);
pstmt.setString(2,”liubin”);
(5)、执行SQL语句。
//执行静态SQL查询
String sql=”select * from users”;
ResultSet rs = stmt.executeQuery(sql);
//执行insert、update、delete等语句,先定义sql
Stmt.executeUpdate(sql);
(6)、访问结果记录集ResultSet对象。
While(rs.next())
{
    out.println(“你的第一个字段内容为:“+rs.getString(1));
    out.println(“你的第二个字段内容为:“+rs.getString(2));
}
(7)、依次将ResultSe


相关文档:

JSP留言管理系统 (附加用户权限功能)

JSP留言管理系统 (附加用户权限功能)
1.游客可以查看通过审核的留言;
2.普通用户登录后可以发表留言,修改密码;
3.管理员登录后可以审核、修改、删除留言;
4.超级管理员登录后可以管理用户,删除用户、修改密码、更改权限。
此留言管理系统包含以下文件:
1.首页(index.jsp):按发表时间倒序显示留言内容,不同权 ......

JSP STRUTS ECLIPSE 编码问题

jsp的pageEncoding="UTF-8",struts的encoding="UTF-8",eclipse 的工作区间的编码方式是GBK,但是在struts的action中获得的jsp传来的中文中有乱码,使用new String(sysgkForm.getContent().getBytes("UTF-8"),"GBK")转码也不行,最后发现问题出在了jsp里面。加上contentType="text/html; charset=GBK" 就好了。
pageEncodi ......

JSP与Servlet的相互通信方式(一)

     JSP与Servlet之间的会话跟踪方式有多个,注定他们的通信方式有多种。
    下面先来看看4中会话跟踪方式:
     一:Session
     传送端:
      HttpSession session=request.getSession();
sessio ......

JSP 隐式对象

·pageContext:提供对页面属性的访问。
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
pageContext.setAttribute("basePath",basePath);
%>
使用:
${pageScope}
 
·reques ......

Jsp 引用 css 样式文件无效的问题解决

修改了css 样式文件后,重新浏览该jsp页面,发现新修改的样式没有生效。总以为是项目缓存所引起的,于是清理所有项目,重新构建项目。不行。执行server 的 publish 还是不行。用window 的搜索功能发现除了 WebContent 目录有该 css 文件外,.metadata\.plugins\org.eclipse.wst.server.core\tmp1\webapps\ 目录下也存在该 c ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号