BlogServlet.java.svn-base
资源名称:cindyblog.rar [点击查看]
上传用户:cdpainuo
上传日期:2022-07-12
资源大小:5257k
文件大小:2k
源码类别:
Jsp/Servlet
开发平台:
Java
- package com.appspot.cindyblog.servlet;
- import java.io.IOException;
- import java.io.PrintWriter;
- import javax.persistence.EntityManager;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.appspot.cindyblog.common.EMF;
- import com.appspot.cindyblog.pojo.ArticleBean;
- import com.appspot.cindyblog.pojo.DiscussBean;
- import com.appspot.cindyblog.pojo.LinkBean;
- import com.appspot.cindyblog.pojo.MessageBean;
- import com.appspot.cindyblog.pojo.TypeBean;
- public class BlogServlet extends BaseServlet {
- private static final long serialVersionUID = 5709330878821727568L;
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- String m = request.getParameter("m");
- if("getIndex".equals(m)){
- this.getIndex(request, response);
- }
- }
- public void getIndex(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- response.setContentType("text/html;charset=utf-8");
- EntityManager em = null;
- try{
- bs = getBlogService();
- em = EMF.get().createEntityManager();
- String rz = bs.getObjectList(ArticleBean.class, em, "time", 0, 5);
- String ly = bs.getObjectList(MessageBean.class, em, "time", 0, 5);
- String fl = bs.getObjectList(TypeBean.class, em);
- String pl = bs.getObjectList(DiscussBean.class, em, "time", 0, 5);
- String link = bs.getObjectList(LinkBean.class, em);
- String str = "var elements = {nodes:{ly:"+ly+",fl:"+fl+",rz:"+rz+",pl:"+pl+",link:"+link+"}}";
- response.getWriter().print(str);
- }catch(Exception e){
- e.printStackTrace();
- }finally{
- closeEntityManager(em);
- }
- }
- }