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

JSP生成静态页面

JDK 1.5 +ECLIPSE +TOMCAT 5.0.28 + MYSQL 5.0
数据库TEST ,表名news
字段: id    int 自动增长 , Title   varchar(20) , Content   varchar(200)   , Author   varchar(10)
makeFile.jsp
<%
   Connection conn = DBconn.getConnection();
   Statement stmt = conn.createStatement();
   ResultSet Rs = stmt.executeQuery("select * from news");
   System.out.println("success");
%>
   <%
  
   String filePath = request.getRealPath("/")+"template.htm";
   System.out.println(filePath);
  
   String templateContent;
   FileInputStream fileinputstream = new FileInputStream(filePath);
   int lenght = fileinputstream.available(); //available() 返回可以不受阻塞地从此文件输入流中读取的字节数。
  
byte bytes[] = new byte[lenght];
fileinputstream.read(bytes); //read(byte[] b) 从此输入流中将最多 b.length 个字节的数据读入一个字节数组中。
fileinputstream.close();
//templateContent = new String(bytes);
String title;
String content;
String author;
while(Rs.next())
{
templateContent = new String(bytes);//如果不用这句,则替换一次之后,templateContent中就没有#**#标志了。所以要重新生成
title = Rs.getString("Title");
content = Rs.getString("Content");
author = Rs.getString("Author");
out.println(title+"********"+content+"****"+author);
out.print("以下是模板内容:<br>"+templateContent+"<br> 以下是置换以后的html内容<br><hr>");
templateContent=templateContent.replaceAll("#title#",title);
templateContent=templateContent.replaceAll("#author#",author);//替换掉模块中相应的地方
templateContent=templateContent.replaceAll("#content#",content);
// 根据时间得文件名
Calendar calendar = Calendar.getInstance();
String fileame = String.valueOf(calendar.getTimeInMillis()) +".html";
fileame = request.getRealPath("/")+"Html/"+fileame;//生成的html文件保存路径
out.print(


相关文档:

JSP 如何实现网页定时跳转:


JSP 如何实现网页定时跳转: 
<script   language="javascript">  
  <!--  
  setTimeout("document.location.href='http://www.163.com'",3000);  
  //-->  
  </script>
刷新:
<meta   http-equiv="Refresh"   content ......

常用jsp技巧

1. 如何让选中的一行记录高亮显示?
http://topic.csdn.net/t/20050105/09/3699823.html
2. 如何在下拉列表框里选择一个值后跳出新窗口?
http://topic.csdn.net/t/20050107/15/3707444.html
3. 如何在JSP中启动execl?
http://community.csdn.net/Expert/TopicView1.asp?id=4909154
http://community.csdn.net/Expert/ ......

JSP/Servlet中解析乱码乱码问题

 在JSP/Servlet 中主要有以下几个地方可以设置编码,pageEncoding="UTF-8"、contentType="text/html;charset=UTF -8"、request.setCharacterEncoding("UTF-8")和response.setCharacterEncoding ("UTF-8"),其中前两个只能用于JSP中,而后两个可以用于JSP和Servlet中。
1、pageEncoding="UTF-8"的作用是设置JSP编译成 ......

用JFreeChart增强JSP报表的用户体验(1)

JFreeChart是一组功能强大、灵活易用的Java绘图API,使用它可以生成多种通用性的报表,包括柱状图、饼图、曲线图、甘特图等。它能够用在Swing和Web等中制作自定义的图表或报表,并且得到广泛的应用。本文将通过引领读者学习在JFreeChart中饼图、柱状图和曲线图的进阶应用,来达到熟练使用JFreeChart的目的。
一. &nb ......

jsp 采集 小偷程序

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.net.URL"%>
<%
URL url = new URL("http://www.itpub.net");//建立URL对象,并实例化为url,获得要抓取的网页地址
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(),"GB2312")); ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号