📄 replyservlet.java
字号:
package ynuServlet;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import ynuBean.AdviceReportBean;
import ynuBean.GetDate;
import ynuBean.ReplyBean;
import ynuBean.ReplyEntity;
public class ReplyServlet extends HttpServlet
{
public void init()throws ServletException
{
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
sendsql(request,response);
}
public void sendsql(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException
{
executeSql(request,response);
}
public void executeSql(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException
{
HttpSession session = request.getSession();
String toJsp = "/reply.jsp";
ReplyBean aReplyBean = new ReplyBean();
String title = (String)session.getAttribute("title");
String username = (String)session.getAttribute("username");
GetDate aDate = new GetDate();
String replyDate = aDate.getDateAndTime();
String replyContent = request.getParameter("replycontent");
System.out.println("The reply of content is "+ replyContent);
//replyContent = new String(replyContent.getBytes("ISO-8859-1"),"UTF-8");
ReplyEntity aReplyEntity = new ReplyEntity(title,username,replyDate,replyContent);
String imsg = aReplyBean.insertReply(aReplyEntity);
session.setAttribute("imsg", imsg);
RequestDispatcher dispatcher = request.getRequestDispatcher(toJsp);
//dispatcher = request.getRequestDispatcher(toJsp);
response.setHeader("Refresh", "0.1; URL=/PesticideInfoManagement"+toJsp+"");
dispatcher.forward(request, response);
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
doGet(request, response);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -