package servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.List;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import bean.reply;
import bean.topics;
import dao.replydao;
import dao.topicdao;
public class Reply extends HttpServlet {
/**
* Constructor of the object.
*/
public Reply() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
request.setAttribute("isview", "l");
int pages=1;
int toPage = 1;
int pageSize = 6;//页面大小
int replyNum=0;
int postID;
if(request.getAttribute("postID")!=null)
postID=Integer.parseInt(request.getAttribute("postID").toString());
else {
postID=Integer.parseInt(request.getParameter("postID"));
}
topics tp;
try {
tp = topicdao.gettopics(postID);
request.setAttribute("tp", tp);
} catch (SQLException | NamingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//设置页面总数
if(request.getParameter("sum")==null){
try {
pages = replydao.getCount(postID);
} catch (SQLException | NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(pages==0)
{
pages=1;
}
if(pages%pageSize==0)
pages = pages/pageSize;
else
pages = pages/pageSize+1;
}
else
pages = Integer.valueOf(request.getParameter("sum").toString());
//获取要到的页面
if(request.getParameter("topage")!=null)
toPage = Integer.valueOf(request.getParameter("topage").toString());
if(toPage<1)
{
toPage=1;
}
if(toPage>pages)
{
toPage=pages;
}
//获取页面的内容
try {
List<reply> list = replydao.getreply(pageSize, toPage, postID);
topicdao.updatebrowse(postID);
request.setAttribute("list", list);
} catch (NamingException | SQLException e) {
e.printStackTrace();
}
request.setAttribute("topage", toPage);
request.setAttribute("pages", pages);
request.getRequestDispatcher("/reply.jsp").forward(request, response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
JSP大作业:实现论坛设计
共51个文件
class:13个
java:13个
jsp:8个
需积分: 11 10 下载量 81 浏览量
2018-05-07
10:17:35
上传
评论 4
收藏 1.19MB ZIP 举报
温馨提示
1、 采用JSP+Bean+Servlet+Dao模式 2、 必须具备用户注册、用户登陆、浏览主题(主页)、查看回复、发表新主题、回复主题 3、 各页面之间的逻辑关系要合理、通顺; 4、 风格设计统一; 5、采用了数据库存储内容 6、文档中有源代码和SQL语句(创建三个数据表-用户表、论坛主页表、帖子回复表)
资源推荐
资源详情
资源评论
收起资源包目录
JSP大作业-论坛.zip (51个子文件)
JSP大作业-论坛
forum
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.project.facet.core.xml 414B
org.eclipse.wst.common.component 474B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 564B
org.eclipse.jdt.core.prefs 364B
src
dao
dataConn.java 342B
topicdao.java 3KB
replydao.java 2KB
dataDao.java 3KB
bean
users.java 690B
topics.java 1KB
reply.java 1KB
servlet
Sendpost.java 2KB
Login.java 3KB
Register.java 3KB
SendReply.java 3KB
Topics.java 3KB
Reply.java 4KB
.project 1KB
WebRoot
_009.jpg 72KB
META-INF
context.xml 437B
MANIFEST.MF 39B
registerinfo.jsp 907B
WEB-INF
web.xml 2KB
classes
dao
dataConn.class 747B
topicdao.class 4KB
replydao.class 3KB
dataDao.class 4KB
bean
users.class 1KB
reply.class 2KB
topics.class 2KB
servlet
SendReply.class 3KB
Sendpost.class 2KB
Reply.class 3KB
Register.class 2KB
Topics.class 3KB
Login.class 2KB
lib
commons-beanutils-1.9.3.jar 240KB
sqljdbc42.jar 870KB
commons-logging-1.2.jar 60KB
reply.jsp 3KB
w14.png 9KB
login.jsp 1KB
index.jsp 3KB
logininfo.jsp 1KB
register.jsp 2KB
sendpost.jsp 1KB
logout.jsp 1019B
.classpath 1KB
1.sql 7KB
共 51 条
- 1
资源评论
JerryHuio
- 粉丝: 2
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功