利用servlet输出CSS
来源:互联网 发布:高清网络电视播放器 编辑:程序博客网 时间:2024/06/05 06:10
import java.sql.Connection;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import util.HtmlPage;
import util.Mail;
import util.PubFun;
public class CssCtrl extends HttpServlet ...{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException ...{
String jspStr = "Page参数不能为空";
Connection conn = null;
resp.setContentType("text; charset=UTF-8");
HtmlPage page = new page.newadmin.LoadTemplatePage();//initHtmlPage(req.getParameter("cssid"));
ServletOutputStream out = resp.getOutputStream();
if (page == null) ...{
resp.sendRedirect("http://www.61live.com/index.html");
out.close();
return;
}
try ...{
conn = PubFun.getConn(true);
page.prepare(conn, req, resp);
jspStr = page.print();
} catch (Exception e) ...{
System.out.println(e.toString());
jspStr = e.toString();
Mail.send("xukai@61live.com", "xukai@61live.com",req.getRequestURI()+"?"+ req
.getQueryString(), e.getMessage(), null, "xukai@61live.com",
"xukai");
Mail.send("litao@61live.com", "xukai@61live.com",req.getRequestURI()+"?"+ req
.getQueryString(), e.getMessage(), null, "xukai@61live.com",
"xukai");
} finally ...{
if (conn != null) ...{
try ...{
conn.close();
} catch (SQLException e2) ...{
System.out.println(page.getClass().getName() + "conn.close() falied");
}
}
}
if(jspStr!=null)...{
out.print(jspStr);
}
out.close();
}
@Override
protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1)
throws ServletException, IOException ...{
// TODO Auto-generated method stub
super.doPost(arg0, arg1);
}
private static HtmlPage initHtmlPage(String page) ...{
if (page.equals("LoadTemplatePage")) // 选择已有的图片标签
return new page.newadmin.LoadTemplatePage();
return null;
}
}
二、读取模板信息
import util.HtmlPage;
import javabean.Template;
public class LoadTemplatePage extends HtmlPage ...{
public String print() throws Exception ...{
long cssid = this.getLongParameter("cssid", -1);
// 此文章的模板信息
Template temp = table.TemplateTable.selctTemplate(conn_, cssid);
StringBuffer strVal = new StringBuffer(temp.getCssCont());
return strVal.toString();
}
}
三、JSP页面 读取CSS
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import="javabean.Template" import="javabean.TopicTag"
%>
<%
Template template = (Template)request.getAttribute("template");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><%=art.getTitle()+"-成长网" %></title>
<meta name="description" content="<%=art.getPicDesc() %>" />
<meta name="keywords" content=" <%=art.getKeyword() %>" />
<%if(template==null){ %>
<link href="<%=request.getContextPath() _fcksavedurl=""<%=request.getContextPath()" %>/webapp/css/deafchild/style.css" rel="stylesheet" type="text/css" />
<%}else{ %>
<link href="<%=request.getContextPath()%>/webapp/css/deafchild/CssCtrl?cssid=<%=template.getCssId() %>" rel="stylesheet" type="text/css" />
<%} %>
四、数据库结构
- 利用servlet输出CSS
- 利用Servlet输出PDF
- Myeclispe 利用Servlet在浏览器中输出 hello world 的源码
- 利用JSP+JS+CSS+Servlet实现用户登录,保存用户名密码功能
- servlet中文输出
- Servlet输出验证码
- 输出HTML的Servlet
- servlet request response 输出
- Servlet输出乱码问题
- servlet 输出 javascript 乱码
- http和servlet输出
- servlet输出流图片
- servlet中输出js
- 关于servlet输出
- 想法:网站首页数据全部用xml输出,利用xsl+Css布局
- 利用servlet创建Cookie
- 利用servlet实现上传
- jsp中利用servlet
- ASP编程入门进阶(二十):ADO组件之删除数据记录
- 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
- ASP编程入门进阶(二十):ADO组件之查询数据记录
- 性能调试---(一)性能分析准则---(二)性能分析工具
- ASP编程入门进阶(廿一):DAO SQL之建立数据库表
- 利用servlet输出CSS
- 我的一个日期操作
- 正是开始写自己的博客
- WORD技巧百分百之格式篇
- 进程间管道通信
- 我们为什么不外包?让专业的人做专业的事情
- cuug大家知道吗
- 水晶报表注册码
- 一些隐藏的Javascript的方法2