王馨苑第二次上传

master
王馨苑 11 months ago
parent 5544568eef
commit 377d8f35e0

@ -1,249 +0,0 @@
package com.action;
/**
*
*/
import java.io.IOException;
import java.util.List;
import java.util.StringTokenizer;
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 com.bean.AdminBean;
import com.bean.SystemBean;
import com.util.Constant;
import com.util.MD5;
public class AdminAction extends HttpServlet {
/**
* Constructor of the object.
*/
public AdminAction() {
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 {
doPost(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 {
response.setContentType(Constant.CONTENTTYPE);
request.setCharacterEncoding(Constant.CHARACTERENCODING);
try{
String method=request.getParameter("method").trim();
AdminBean loginbean = new AdminBean();
HttpSession session = request.getSession();
session.setMaxInactiveInterval(1200);
SystemBean systembean = new SystemBean();
String sysdir = systembean.getDir();
if(method.equals("one")){//admin登录
String username = request.getParameter("username");
String password = request.getParameter("password");
if(username == null||username.trim().equals("")){
request.setAttribute("message", "请正确输入用户名!");
request.getRequestDispatcher(sysdir+"/login.jsp").forward(request, response);
}
else if(password == null||password.trim().equals("")){
request.setAttribute("message", "请输入密码!");
request.getRequestDispatcher(sysdir+"/login.jsp").forward(request, response);
}
else{
String md5password = MD5.MD5(password);
String agent = request.getHeader("user-agent");
StringTokenizer st = new StringTokenizer(agent,";");
String useros=st.nextToken();
String loginip = request.getRemoteAddr();
int flag = loginbean.adminLogin(username,md5password, password,useros,loginip);
switch (flag){
case Constant.SUCCESS:
List list = loginbean.getAdminInfo(username);
session.setAttribute("user", username);
session.setAttribute("list", list);
request.getRequestDispatcher(sysdir+"/").forward(request, response);
break;
case Constant.NAME_ERROR:
request.setAttribute("message", "用户名错误!请确认管理权限!");
request.getRequestDispatcher(sysdir+"/login.jsp").forward(request, response);
break;
case Constant.PASSWORD_ERROR:
request.setAttribute("message", "密码错误,请确认管理权限!");
request.getRequestDispatcher(sysdir+"/login.jsp").forward(request, response);
break;
}
}
}
else if(method.equals("editpwd")){//admin edit password
String username2 = (String)session.getAttribute("user");
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
String oldpwd = MD5.MD5(request.getParameter("oldpwd").trim());
String newpwd = MD5.MD5(request.getParameter("newpwd").trim());
String username = (String)session.getAttribute("user");
int flag = loginbean.editPassword(username, oldpwd, newpwd);
switch (flag){
case Constant.SUCCESS:
request.setAttribute("message", "密码修改成功!");
request.getRequestDispatcher(sysdir+"/system/editpwd.jsp").forward(request, response);
break;
case Constant.PASSWORD_ERROR:
request.setAttribute("message", "原始密码错误,请确认权限!");
request.getRequestDispatcher(sysdir+"/system/editpwd.jsp").forward(request, response);
break;
case Constant.SYSTEM_ERROR:
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/system/editpwd.jsp").forward(request, response);
break;
}
}
}
else if(method.equals("exit")){//admin exit
String username2 = (String)session.getAttribute("user");
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
session.removeAttribute("user");
session.removeAttribute("list");
System.gc();
request.getRequestDispatcher(sysdir+"/login.jsp").forward(request, response);
}
}
else if(method.equals("manager")){//add,update manager
String username2 = (String)session.getAttribute("user");
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
String username = request.getParameter("username").trim();
String password = MD5.MD5(request.getParameter("password").trim());
int flag = loginbean.addManager(username, password, "2", "1");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "增加管理员成功!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}
else if(flag == Constant.SAME_NAME){
request.setAttribute("username", username);
request.setAttribute("message", "该用户名已经存在!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}
}
}
else if(method.equals("delm")){//delete manager
String username2 = (String)session.getAttribute("user");
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
int id = Integer.parseInt(request.getParameter("id").trim());
if(id == 1){
request.setAttribute("message", "不能删除原始帐号!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}
else{
int flag = loginbean.delManager(id);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "删除成功!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}
}
}
}
else if(method.equals("dellog")){//delete login note
String username2 = (String)session.getAttribute("user");
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
String check[] = request.getParameterValues("checkit");
if(check == null){
request.setAttribute("message", "请选择要删除的记录!");
request.getRequestDispatcher(sysdir+"/system/log.jsp").forward(request, response);
}
else{
int id[]= new int[check.length];
for(int i = 0;i<check.length;i++){
int s = Integer.parseInt(check[i]);
id[i] = s;
}
int flag = loginbean.delLog(id);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "删除记录成功!");
request.getRequestDispatcher(sysdir+"/system/log.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/system/log.jsp").forward(request, response);
}
}
}
}
else{//无参数传入转到错误页面
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}catch(Exception e){
e.printStackTrace();
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}

@ -1,160 +0,0 @@
package com.action;
/**
*
* @author Administrator
*
*/
import java.io.IOException;
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 com.bean.AfficheBean;
import com.bean.SystemBean;
import com.util.Constant;
import com.util.Filter;
public class AfficheAction extends HttpServlet {
/**
* Constructor of the object.
*/
public AfficheAction() {
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 {
doPost(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 {
response.setContentType(Constant.CONTENTTYPE);
request.setCharacterEncoding(Constant.CHARACTERENCODING);
String sysdir = new SystemBean().getDir();
HttpSession session = request.getSession();
try{
String username2 = (String)session.getAttribute("user");
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
AfficheBean afficheBean = new AfficheBean();
String method = request.getParameter("method").trim();
if(method.equals("addAffiche")){//增加公告
String title = Filter.escapeHTMLTags(request.getParameter("title").trim());
String content = Filter.escapeHTMLTags(request.getParameter("content").trim());
String adder = username2;
String ifhide = Filter.escapeHTMLTags(request.getParameter("ifhide").trim());
int flag = afficheBean.addAffiche(title, content, adder, ifhide);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中请稍后再试!");
request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response);
}
}
else if(method.equals("editAffiche")){//修改公告
String id=Filter.escapeHTMLTags(request.getParameter("id").trim());
String title = Filter.escapeHTMLTags(request.getParameter("title").trim());
String content = Filter.escapeHTMLTags(request.getParameter("content").trim());
String adder = username2;
String ifhide = Filter.escapeHTMLTags(request.getParameter("ifhide").trim());
int flag = afficheBean.updateAffiche(Integer.parseInt(id), title, content, adder, ifhide);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中请稍后再试!");
request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response);
}
}
else if(method.equals("hideAffiche")){
String id = Filter.escapeHTMLTags(request.getParameter("id").trim());
int flag = afficheBean.hideAffiche(Integer.parseInt(id));
if(flag == Constant.SUCCESS){
request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response);
}
}
else if(method.equals("delaffiche")){//删除公告
String check[] = request.getParameterValues("checkit");
if(check == null){
request.setAttribute("message", "请选择要删除的记录!");
request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response);
}
else{
int id[]= new int[check.length];
for(int i = 0;i<check.length;i++){
int s = Integer.parseInt(check[i]);
id[i] = s;
}
int flag = afficheBean.delAffiche(id);
if(flag == Constant.SUCCESS){
request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response);
}
}
}
}
}catch(Exception e){
e.printStackTrace();
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}

@ -1,172 +0,0 @@
package com.action;
/**
* servlet
*
*
*
*/
import java.io.IOException;
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 com.bean.NewsBean;
import com.bean.SystemBean;
import com.util.Constant;
import com.util.Filter;
public class CommonAction extends HttpServlet {
/**
* Constructor of the object.
*/
public CommonAction() {
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 {
doPost(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 {
response.setContentType(Constant.CONTENTTYPE);
request.setCharacterEncoding(Constant.CHARACTERENCODING);
String sysdir = new SystemBean().getDir();
HttpSession session = request.getSession();
try{
String username2 = (String)session.getAttribute("user");
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
String method = request.getParameter("method").trim();
/**********************************************
*
************************************************/
if(method.equals("DELNEWS")){//删除新闻 来自普通新闻页面index.jsp
String strDirPath = request.getSession().getServletContext().getRealPath("/");
String check[] = request.getParameterValues("checkit");
if(check == null){
request.setAttribute("message", "请选择要删除的记录!");
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
else{
int id2[]= new int[check.length];
for(int i = 0;i<check.length;i++){
int s = Integer.parseInt(check[i]);
id2[i] = s;
}
int flag = new NewsBean().delNews(id2);
if(flag == Constant.SUCCESS){
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
}
}
else if(method.equals("HIDENEWS")){//隐藏、显示新闻 来自普通新闻页面index.jsp
String id = Filter.escapeHTMLTags(request.getParameter("id").trim());
int flag = new NewsBean().hideNews(Integer.parseInt(id));
if(flag == Constant.SUCCESS){
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
}
else if(method.equals("UPNEWS")){//置顶 新闻 来自普通新闻页面index.jsp
String id = Filter.escapeHTMLTags(request.getParameter("id").trim());
int flag = new NewsBean().upNews(Integer.parseInt(id));
if(flag == Constant.SUCCESS){
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
}
// if(method.equals("DELUPNEWS")){//删除新闻 来自置顶新闻页面up.jsp
// String strDirPath = request.getSession().getServletContext().getRealPath("/");
// String check[] = request.getParameterValues("checkit");
// if(check == null){
// request.setAttribute("message", "请选择要删除的记录!");
// request.getRequestDispatcher(sysdir+"/news/up.jsp").forward(request, response);
// }
// else{
// int id2[]= new int[check.length];
// for(int i = 0;i<check.length;i++){
// int s = Integer.parseInt(check[i]);
// id2[i] = s;
// }
// int flag = new NewsBean().delNews(id2,strDirPath);
// if(flag == Constant.SUCCESS){
// request.getRequestDispatcher(sysdir+"/news/up.jsp").forward(request, response);
// }
// else{
// request.setAttribute("message", "系统维护中,请稍后再试!");
// request.getRequestDispatcher(sysdir+"/news/up.jsp").forward(request, response);
// }
// }
// }
else{
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
}catch(Exception e){
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}

@ -1,193 +0,0 @@
package com.action;
/**
*
*
*/
import java.io.IOException;
import java.util.List;
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 com.bean.GuestBookBean;
import com.bean.SystemBean;
import com.util.Constant;
import com.util.Filter;
public class GuestBookAction extends HttpServlet {
/**
* Constructor of the object.
*/
public GuestBookAction() {
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 {
doPost(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 {
request.setCharacterEncoding(Constant.CHARACTERENCODING);
response.setContentType(Constant.CONTENTTYPE);
//nikename, pic, email, qq, weburl, blogurl, expressions, content
String sysdir = new SystemBean().getDir();
HttpSession session = request.getSession();
String method = request.getParameter("method").trim();
GuestBookBean guestBookBean = new GuestBookBean();
if(method.equals("add")){//发表留言
String member=(String)session.getAttribute("member");
String nikename = Filter.escapeHTMLTags(request.getParameter("nikename").trim());
String face ="images/nobody.gif";
String email = Filter.escapeHTMLTags(request.getParameter("email").trim());
String qq = Filter.escapeHTMLTags(request.getParameter("qq").trim());
String weburl = Filter.escapeHTMLTags(request.getParameter("weburl").trim());
String blogurl = Filter.escapeHTMLTags(request.getParameter("blogurl").trim());
String expressions = "images/face/"+Filter.escapeHTMLTags(request.getParameter("face").trim())+".gif";
String content = Filter.escapeHTMLTags(request.getParameter("content").trim());
String ip = request.getRemoteAddr();
int guestbook=1;
int flag = guestBookBean.addGuestBook(nikename, face, email, qq, weburl, blogurl, expressions, content, ip,guestbook);
if(flag == 1){
request.setAttribute("message", "谢谢您的留言,请等候管理员回复!");
request.getRequestDispatcher("guestbook.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("guestbook.jsp").forward(request, response);
}
}
else if(method.equals("delguestbook")){//删除留言
try{
String username2 = (String)session.getAttribute("user");
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
String check[] = request.getParameterValues("checkit");
if(check == null){
request.setAttribute("message", "请选择要删除的记录!");
request.getRequestDispatcher(sysdir+"/guestbook/index.jsp").forward(request, response);
}
else{
int id[]= new int[check.length];
for(int i = 0;i<check.length;i++){
int s = Integer.parseInt(check[i]);
id[i] = s;
}
int flag = guestBookBean.delGuestBook(id);
if(flag == Constant.SUCCESS){
request.getRequestDispatcher(sysdir+"/guestbook/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/guestbook/index.jsp").forward(request, response);
}
}
}
}catch(Exception e){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
else if(method.equals("replay")){//回复留言
try{
String username2 = (String)session.getAttribute("user");
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
String messageid = Filter.escapeHTMLTags(request.getParameter("id").trim());
String replay = Filter.escapeHTMLTags(request.getParameter("replay").trim());
int flag = guestBookBean.reGuestBook(Integer.parseInt(messageid), replay, username2);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "回复成功!");
request.getRequestDispatcher(sysdir+"/guestbook/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/guestbook/index.jsp").forward(request, response);
}
}
}catch(Exception e){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
else if(method.equals("upreplay")){
try{
String username2 = (String)session.getAttribute("user");
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
String messageid = Filter.escapeHTMLTags(request.getParameter("id").trim());
String replay = Filter.escapeHTMLTags(request.getParameter("replay").trim());
int flag = guestBookBean.upReplay(Integer.parseInt(messageid), replay);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "修改成功!");
request.getRequestDispatcher(sysdir+"/guestbook/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/guestbook/index.jsp").forward(request, response);
}
}
}catch(Exception e){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
else{
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}

@ -1,157 +0,0 @@
package com.action;
import java.io.IOException;
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 com.bean.HzpBean;
import com.bean.NewsBean;
import com.util.Constant;
public class HzpAction extends HttpServlet {
/**
* Constructor of the object.
*/
public HzpAction() {
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 {
doPost(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 {
request.setCharacterEncoding(Constant.CHARACTERENCODING);
response.setContentType(Constant.CONTENTTYPE);
HttpSession session=request.getSession();
HzpBean tb=new HzpBean();
String method=request.getParameter("method").trim();
/////////////////////////////////////////////////////////////////////
if(method.equals("deltrave")){
String id=request.getParameter("id").trim();
int flag = tb.delTrave(id);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("admin/hzp/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("admin/hzp/index.jsp").forward(request, response);
}
}
else if(method.equals("hotdeltrave")){
String id=request.getParameter("id").trim();
int flag = tb.delTrave(id);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("admin/hzp/hot.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("admin/hzp/hot.jsp").forward(request, response);
}
}
else if(method.equals("tejiadeltrave")){
String id=request.getParameter("id").trim();
int flag = tb.delTrave(id);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("admin/hzp/tejia.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("admin/hzp/tejia.jsp").forward(request, response);
}
}
else if(method.equals("tuijiandeltrave")){
String id=request.getParameter("id").trim();
int flag = tb.delTrave(id);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("admin/hzp/tuijian.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("admin/hzp/tuijian.jsp").forward(request, response);
}
}
else if(method.equals("addType")){
String type=request.getParameter("type").trim();
int flag=tb.addType(type);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("admin/hzp/type.jsp").forward(request, response);
}
else if(flag==Constant.DEFAULT_ERROR){
request.setAttribute("message", "该分类已存在!");
request.getRequestDispatcher("admin/hzp/type.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("admin/hzp/type.jsp").forward(request, response);
}
}
else if(method.equals("delType")){
String id=request.getParameter("id").trim();
int flag=tb.delType(id);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("admin/hzp/type.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("admin/hzp/type.jsp").forward(request, response);
}
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}

@ -1,163 +0,0 @@
package com.action;
/**
* 退
*
*/
import java.io.IOException;
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 com.bean.MemberBean;
import com.util.Constant;
import com.util.Filter;
public class LoginAction extends HttpServlet {
/**
* Constructor of the object.
*/
public LoginAction() {
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 {
doPost(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 {
response.setContentType(Constant.CONTENTTYPE);
request.setCharacterEncoding(Constant.CHARACTERENCODING);
HttpSession session = request.getSession();
MemberBean memberBean = new MemberBean();
String method = Filter.escapeHTMLTags(request.getParameter("method").trim());
if(method.equals("HEADUSERLOGIN")){//网页头部会员登陆
String reg_user = Filter.escapeHTMLTags(request.getParameter("reg_user").trim());
String reg_pwd = Filter.escapeHTMLTags(request.getParameter("reg_pwd").trim());
String reg_type = Filter.escapeHTMLTags(request.getParameter("reg_type").trim());
String lastip = request.getRemoteAddr();
int flag = memberBean.memberLogin(reg_user, reg_pwd, reg_type);
if(flag == Constant.SUCCESS){//登陆成功
String info = memberBean.getLastTimeIP(reg_user);
int flag2 = memberBean.upmemberLogin(reg_user, lastip);
if(flag2 == Constant.SUCCESS){
session.setAttribute("member", reg_user);
session.setAttribute("type", reg_type);
session.setAttribute("info", info);
request.getRequestDispatcher("login1.jsp").forward(request, response);
}
else{
session.setAttribute("member", reg_user);
session.setAttribute("type", reg_type);
session.setAttribute("info", info);
session.setAttribute("message", "登陆成功,登陆信息更新失败!");
request.getRequestDispatcher("login1.jsp").forward(request, response);
}
}
else if(flag == Constant.NAME_ERROR){//用户名错误
request.setAttribute("reg_user", reg_user);
request.setAttribute("message", "该用户名不存在或者已被管理员冻结!");
request.getRequestDispatcher("login1.jsp").forward(request, response);
}
else if(flag == Constant.PASSWORD_ERROR){//密码错误
request.setAttribute("reg_user", reg_user);
request.setAttribute("message", "密码错误!");
request.getRequestDispatcher("login1.jsp").forward(request, response);
}
}
else if(method.equals("PAGEUSERLOGIN")){//登陆页面会员登陆
String username = Filter.escapeHTMLTags(request.getParameter("username").trim());
String password = Filter.escapeHTMLTags(request.getParameter("password").trim());
String reg_type = Filter.escapeHTMLTags(request.getParameter("reg_type").trim());
String lastip = request.getRemoteAddr();
int flag = memberBean.memberLogin(username, password, reg_type);
if(flag == Constant.SUCCESS){//登陆成功
String info = memberBean.getLastTimeIP(username);
int flag2 = memberBean.upmemberLogin(username, lastip);
if(flag2 == Constant.SUCCESS){
session.setAttribute("member", username);
session.setAttribute("type", reg_type);
session.setAttribute("info", info);
request.getRequestDispatcher("member/index.jsp").forward(request, response);
}
else{
session.setAttribute("member", username);
session.setAttribute("type", reg_type);
session.setAttribute("info", info);
session.setAttribute("message", "登陆成功,登陆信息更新失败!");
request.getRequestDispatcher("member/index.jsp").forward(request, response);
}
}
else if(flag == Constant.NAME_ERROR){//用户名错误
request.setAttribute("reg_user", username);
request.setAttribute("message", "该用户名不存在!");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
else if(flag == Constant.PASSWORD_ERROR){//密码错误
request.setAttribute("reg_user", username);
request.setAttribute("message", "密码错误!");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
}
else if(method.equals("logout")){//从iframe页面退出登陆
session.removeAttribute("member");
session.removeAttribute("type");
request.getRequestDispatcher("login1.jsp").forward(request, response);
}
else if(method.equals("pagelogout")||method.equals("memberexit")){//从网页退出登陆
session.removeAttribute("member");
session.removeAttribute("type");
request.getRequestDispatcher("index.jsp").forward(request, response);
}
else{
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}

@ -1,258 +0,0 @@
package com.action;
/**
*
* @author Administrator
*
*/
import java.io.IOException;
import java.util.List;
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 com.bean.MemberBean;
import com.bean.SystemBean;
import com.util.Constant;
import com.util.Filter;
import com.util.MD5;
public class MemberAction extends HttpServlet {
/**
* Constructor of the object.
*/
public MemberAction() {
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 {
doPost(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 {
response.setContentType(Constant.CONTENTTYPE);
request.setCharacterEncoding(Constant.CHARACTERENCODING);
HttpSession session = request.getSession();
MemberBean memberBean = new MemberBean();
String method = Filter.escapeHTMLTags(request.getParameter("method").trim());
/*********************************************
* reg2.jsp
*********************************************/
if(method.equals("reg2")){//会员注册 reg2.jsp
String username = Filter.escapeHTMLTags(request.getParameter("username").trim());
String password = Filter.escapeHTMLTags(request.getParameter("password").trim());
String reg_type = Filter.escapeHTMLTags(request.getParameter("reg_type").trim());
request.setAttribute("username", username);
request.setAttribute("password", password);
request.setAttribute("reg_type", reg_type);
if(username.trim().equals("admin")){
request.setAttribute("username", username);
request.setAttribute("message", "非法的用户名,请重新选择!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else{
int flag = memberBean.checkRegName(username);
if(flag == Constant.SUCCESS){
if(reg_type.equals("person")){//如果是个人会员
request.getRequestDispatcher("personreg.jsp").forward(request, response);
}
else if(reg_type.equals("co")){//如果是企业会员
request.getRequestDispatcher("coreg.jsp").forward(request, response);
}
else{
request.getRequestDispatcher("index.jsp").forward(request, response);
}
}
else if(flag == Constant.SAME_NAME){
request.setAttribute("username", username);
request.setAttribute("message", "对不起,该用户名已存在,请重新选择!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
}
}
else if(method.equals("checksame")){//检查注册名是否可用
String username = Filter.escapeHTMLTags(request.getParameter("username").trim());
if(username.trim().equals("admin")){
request.setAttribute("username", username);
request.setAttribute("message", "非法的用户名,请重新选择!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else{
int flag = memberBean.checkRegName(username);
if(flag == Constant.SUCCESS){
request.setAttribute("username", username);
request.setAttribute("message", "恭喜您,这个名字可以使用!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else if(flag == Constant.SAME_NAME){
request.setAttribute("username", username);
request.setAttribute("message", "对不起,该用户名已存在,请重新选择!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
}
}
else if(method.equals("Editpwd")){//会员修改登陆密码
String member=(String)session.getAttribute("member");
String type=(String)session.getAttribute("type");
if(member==null||type==null){
response.sendRedirect("error.jsp");
}
else{
String oldpwd = MD5.MD5(request.getParameter("oldpwd").trim());
String newpwd = MD5.MD5(request.getParameter("newpwd").trim());
int flag = memberBean.editPassword(member, oldpwd, newpwd);
switch (flag){
case Constant.SUCCESS:
request.setAttribute("message", "密码修改成功!");
request.getRequestDispatcher("member/info/editpwd.jsp").forward(request, response);
break;
case Constant.PASSWORD_ERROR:
request.setAttribute("message", "原始密码错误,请确认权限!");
request.getRequestDispatcher("member/info/editpwd.jsp").forward(request, response);
break;
case Constant.SYSTEM_ERROR:
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("member/info/editpwd.jsp").forward(request, response);
break;
}
}
}
/*********************************************
*
*********************************************/
else if(method.equals("PREG")){//个人会员详细资料
String username = Filter.escapeHTMLTags(request.getParameter("username").trim());
String password = Filter.escapeHTMLTags(request.getParameter("password").trim());
String type = "person";
String realname = Filter.escapeHTMLTags(request.getParameter("realname").trim());
String sex = Filter.escapeHTMLTags(request.getParameter("sex").trim());
String sheng = Filter.escapeHTMLTags(request.getParameter("sheng").trim());
String city = Filter.escapeHTMLTags(request.getParameter("city").trim());
String bir = Filter.escapeHTMLTags(request.getParameter("bir").trim());
String telphone = Filter.escapeHTMLTags(request.getParameter("telphone").trim());
String email = Filter.escapeHTMLTags(request.getParameter("email").trim());
String question = Filter.escapeHTMLTags(request.getParameter("question").trim());
String answer = Filter.escapeHTMLTags(request.getParameter("answer").trim());
String address = Filter.escapeHTMLTags(request.getParameter("address").trim());
String lastip = request.getRemoteAddr();
int off = 1;
int flag = memberBean.personReg(username, password, type, realname, sex, bir,sheng,city, telphone, email, question, answer, lastip, off,address);
if(flag == Constant.SUCCESS){
List siteList = new SystemBean().getSiteInfo();
String sitename = siteList.get(0).toString();
request.setAttribute("message", "注册成功!恭喜您成为"+sitename+"的注册会员!");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("personreg.jsp").forward(request, response);
}
}
else if(method.equals("UPREGINFO")){//个人会员修改资料
String member=(String)session.getAttribute("member");
String type=(String)session.getAttribute("type");
if(member==null||type==null){
response.sendRedirect("error.jsp");
}
else{
String realname = Filter.escapeHTMLTags(request.getParameter("realname").trim());
String sex = Filter.escapeHTMLTags(request.getParameter("sex").trim());
String sheng = Filter.escapeHTMLTags(request.getParameter("sheng").trim());
String city = Filter.escapeHTMLTags(request.getParameter("city").trim());
String bir = Filter.escapeHTMLTags(request.getParameter("bir").trim());
String telphone = Filter.escapeHTMLTags(request.getParameter("telphone").trim());
String email = Filter.escapeHTMLTags(request.getParameter("email").trim());
String question = Filter.escapeHTMLTags(request.getParameter("question").trim());
String answer = Filter.escapeHTMLTags(request.getParameter("answer").trim());
String address = Filter.escapeHTMLTags(request.getParameter("address").trim());
int flag = memberBean.uppersonReg(member, realname, sex, bir, sheng, city, telphone, email, question, answer,address);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("member/info/info.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("member/info/info.jsp").forward(request, response);
}
}
}
else if(method.equals("lostpwd")){
String username=request.getParameter("username");
String question=request.getParameter("question");
String answer=request.getParameter("answer");
String reg_type=request.getParameter("reg_type");
String info=memberBean.returnPwd(username, question, answer, reg_type);
if(info.trim().equals("error")){
request.setAttribute("message", "信息错误!");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
else{
request.setAttribute("message", "您的新密码为"+info+",请登录后修改!");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
}
else{
request.getRequestDispatcher("index.jsp").forward(request, response);
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}

@ -1,178 +0,0 @@
package com.action;
/**
*
*
*/
import java.io.IOException;
import java.util.List;
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 com.bean.MemberManageBean;
import com.bean.SystemBean;
import com.util.Constant;
import com.util.Filter;
public class MemberManageAction extends HttpServlet {
/**
* Constructor of the object.
*/
public MemberManageAction() {
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 {
doPost(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 {
response.setContentType(Constant.CONTENTTYPE);
request.setCharacterEncoding(Constant.CHARACTERENCODING);
String sysdir = new SystemBean().getDir();
HttpSession session = request.getSession();
try{
String username2 = (String)session.getAttribute("user");
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
String method = Filter.escapeHTMLTags(request.getParameter("method").trim());
MemberManageBean mmBean = new MemberManageBean();
if(method.equals("DELMEMBER")||method.equals("DELCO")||method.equals("DELTODAY")
||method.equals("DELALLCLOSE")||method.equals("DELALLUSE")){//删除来自后台各个页面的会员
String check[] = request.getParameterValues("checkit");
if(check == null){
if(method.equals("DELMEMBER")){//来自所有个人会员页面
request.setAttribute("message", "请选择要删除的记录!");
request.getRequestDispatcher(sysdir+"/member/person.jsp").forward(request, response);
}
else if(method.equals("DELCO")){//来自所有企业会员页面
request.setAttribute("message", "请选择要删除的记录!");
request.getRequestDispatcher(sysdir+"/member/co.jsp").forward(request, response);
}
else if(method.equals("DELTODAY")){//来自今日注册会员页面
request.setAttribute("message", "请选择要删除的记录!");
request.getRequestDispatcher(sysdir+"/member/today.jsp").forward(request, response);
}
else if(method.equals("DELALLCLOSE")){//来自所有冻结会员页面
request.setAttribute("message", "请选择要删除的记录!");
request.getRequestDispatcher(sysdir+"/member/close.jsp").forward(request, response);
}
else if(method.equals("DELALLUSE")){//来自所有在用会员页面
request.setAttribute("message", "请选择要删除的记录!");
request.getRequestDispatcher(sysdir+"/member/using.jsp").forward(request, response);
}
}
else{
int id[]= new int[check.length];
for(int i = 0;i<check.length;i++){
int s = Integer.parseInt(check[i]);
id[i] = s;
}
int flag = mmBean.delMember(id);
if(flag == Constant.SUCCESS){
if(method.equals("DELMEMBER")){//来自所有个人会员页面
request.getRequestDispatcher(sysdir+"/member/person.jsp").forward(request, response);
}
else if(method.equals("DELCO")){//来自所有企业会员页面
request.getRequestDispatcher(sysdir+"/member/co.jsp").forward(request, response);
}
else if(method.equals("DELTODAY")){//来自今日注册会员页面
request.getRequestDispatcher(sysdir+"/member/today.jsp").forward(request, response);
}
else if(method.equals("DELALLCLOSE")){//来自所有冻结会员页面
request.getRequestDispatcher(sysdir+"/member/close.jsp").forward(request, response);
}
else if(method.equals("DELALLUSE")){//来自所有在用会员页面
request.getRequestDispatcher(sysdir+"/member/using.jsp").forward(request, response);
}
}
else{
if(method.equals("DELMEMBER")){//来自所有个人会员页面
request.getRequestDispatcher(sysdir+"/member/person.jsp").forward(request, response);
}
else if(method.equals("DELCO")){//来自所有企业会员页面
request.getRequestDispatcher(sysdir+"/member/co.jsp").forward(request, response);
}
else if(method.equals("DELTODAY")){//来自今日注册会员页面
request.getRequestDispatcher(sysdir+"/member/today.jsp").forward(request, response);
}
else if(method.equals("DELALLCLOSE")){//来自所有冻结会员页面
request.getRequestDispatcher(sysdir+"/member/close.jsp").forward(request, response);
}
else if(method.equals("DELALLUSE")){//来自所有在用会员页面
request.getRequestDispatcher(sysdir+"/member/using.jsp").forward(request, response);
}
}
}
}
else if(method.equals("CLOSE")){
String id=request.getParameter("id").trim();
int flag=mmBean.closeMember(Integer.parseInt(id));
if(flag==Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("admin/member/person.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("admin/member/person.jsp").forward(request, response);
}
}
else{
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
}catch(Exception e){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}

@ -1,269 +0,0 @@
package com.action;
/**
* -
*
*/
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.servlet.ServletConfig;
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 com.bean.NewsBean;
import com.bean.SystemBean;
import com.bean.HzpBean;
import com.util.Constant;
import com.util.Filter;
import com.util.SmartFile;
import com.util.SmartUpload;
public class NewsAction extends HttpServlet {
private ServletConfig config;
/**
* Constructor of the object.
*/
public NewsAction() {
super();
}
final public void init(ServletConfig config) throws ServletException
{
this.config = config;
}
final public ServletConfig getServletConfig()
{
return config;
}
/**
* 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 {
doPost(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 {
request.setCharacterEncoding(Constant.CHARACTERENCODING);
response.setContentType(Constant.CONTENTTYPE);
String sysdir = new SystemBean().getDir();
HttpSession session = request.getSession();
String date=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
try{
String username2 = (String)session.getAttribute("user");
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
String method = null;
NewsBean newsBean = new NewsBean();
HzpBean tb=new HzpBean();
SmartUpload mySmartUpload = new SmartUpload();//init
int count = 0;
try{
mySmartUpload.initialize(config,request,response);
mySmartUpload.upload();
method = mySmartUpload.getRequest().getParameter("method").trim();
if(method.equals("ADDNEWS")){//增加新闻
String title = Filter.escapeHTMLTags(mySmartUpload.getRequest().getParameter("title").trim());
String ifhide = Filter.escapeHTMLTags(mySmartUpload.getRequest().getParameter("ifhide").trim());
String content = mySmartUpload.getRequest().getParameter("infoContent");
if(content.length()>8000){
request.setAttribute("message", "对不起新闻内容不能超过8000个字符");
request.setAttribute("method", method);
request.getRequestDispatcher(sysdir+"/news/edit.jsp").forward(request, response);
}
else{
SmartFile file = mySmartUpload.getFiles().getFile(0);
String fileExt=file.getFileExt();
String path="/upload_file/news";
count = mySmartUpload.save(path);
if(file.getFilePathName().trim().equals("")){//如果无缩略图
int flag = newsBean.addNews(title, "无",content, username2, ifhide);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "增加新闻成功!");
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
}
else{
int flag = newsBean.addNews(title, path+"/"+file.getFileName(),content, username2, ifhide);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "增加新闻成功!");
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
}
}
}
else if(method.equals("editnews")){//修改新闻
String id = Filter.escapeHTMLTags(mySmartUpload.getRequest().getParameter("id").trim());
String title = Filter.escapeHTMLTags(mySmartUpload.getRequest().getParameter("title").trim());
String ifhide = Filter.escapeHTMLTags(mySmartUpload.getRequest().getParameter("ifhide").trim());
String content = mySmartUpload.getRequest().getParameter("infoContent");
SmartFile file = mySmartUpload.getFiles().getFile(0);
String fileExt=file.getFileExt();
String path="/upload_file/news";
count = mySmartUpload.save(path);
if(file.getFilePathName().trim().equals("")){//如果不修改缩略图
int flag = newsBean.updateNews(Integer.parseInt(id), title, content, username2, ifhide);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "修改新闻成功!");
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
}
else{//如果修改缩略图
int flag = newsBean.updateNewsWithPic(Integer.parseInt(id), title, path+"/"+file.getFileName(), content, username2, ifhide);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "修改新闻成功!");
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
}
}
////////////////////////////////////////////////////////////////////////////宾馆
else if(method.equals("addlvyou")){//增加
/**
* String title = "";
String dz="";
String yb="";
String dh="";
String jd="";
String content="";
*/
String title = mySmartUpload.getRequest().getParameter("title");
String dz = mySmartUpload.getRequest().getParameter("dz");
String yb = mySmartUpload.getRequest().getParameter("yb");
String dh = mySmartUpload.getRequest().getParameter("dh");
String jd = mySmartUpload.getRequest().getParameter("jd");
String content = mySmartUpload.getRequest().getParameter("infoContent");
String flag11 = mySmartUpload.getRequest().getParameter("flag");
if(content.length()>8000){
request.setAttribute("message", "对不起内容不能超过8000个字符");
request.setAttribute("method", method);
request.getRequestDispatcher(sysdir+"/hzp/add.jsp").forward(request, response);
}
else{
SmartFile file = mySmartUpload.getFiles().getFile(0);
String fileExt=file.getFileExt();
String path="/upload_file/sale";
count = mySmartUpload.save(path);
String sql="insert into sale(title,url,dz,yb,dh,jd,content,addtime) " +
"values('"+title+"','"+path+"/"+file.getFileName()+"','"+dz+"','"+yb+"','"+dh+"','"+jd+"','"+content+"','"+date+"')";
int flag = new NewsBean().exeUp(sql);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher(sysdir+"/hzp/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/hzp/index.jsp").forward(request, response);
}
}
}
//update
else if(method.equals("uplvyou")){
String id = mySmartUpload.getRequest().getParameter("id");
String title = mySmartUpload.getRequest().getParameter("title");
String dz = mySmartUpload.getRequest().getParameter("dz");
String yb = mySmartUpload.getRequest().getParameter("yb");
String dh = mySmartUpload.getRequest().getParameter("dh");
String jd = mySmartUpload.getRequest().getParameter("jd");
String content = mySmartUpload.getRequest().getParameter("infoContent");
String flag11 = mySmartUpload.getRequest().getParameter("flag");
if(content.length()>8000){
request.setAttribute("message", "对不起内容不能超过8000个字符");
request.setAttribute("method", method);
request.getRequestDispatcher(sysdir+"/hzp/add.jsp").forward(request, response);
}
else{
SmartFile file = mySmartUpload.getFiles().getFile(0);
String fileExt=file.getFileExt();
String path="/upload_file/sale";
count = mySmartUpload.save(path);
String sql="update sale set title='"+title+"',url='"+path+"/"+file.getFileName()+"',dz='"+dz+"'," +
"yb='"+yb+"',dh='"+dh+"',jd='"+jd+"',content='"+content+"' where id='"+id+"'";
int flag = new NewsBean().exeUp(sql);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher(sysdir+"/hzp/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/hzp/index.jsp").forward(request, response);
}
}
}
else{
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}catch(Exception ex){
ex.printStackTrace();
//request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
}catch(Exception e){
e.printStackTrace();
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}

@ -1,268 +0,0 @@
package com.action;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Calendar;
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 com.bean.NewsBean;
import com.bean.SystemBean;
import com.util.Constant;
import com.util.Filter;
public class NewsServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public NewsServlet() {
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 {
doPost(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 {
response.setContentType(Constant.CONTENTTYPE);
request.setCharacterEncoding(Constant.CHARACTERENCODING);
String sysdir = new SystemBean().getDir();
HttpSession session = request.getSession();
String date=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
try{
String username2 = (String)session.getAttribute("user");
String method = request.getParameter("method").trim();
if(method.equals("addNews")){
String title = request.getParameter("title");
String fenlei = request.getParameter("fenlei");
String infoContent = request.getParameter("infoContent");
int flag = new NewsBean().exeUp("insert into news(title,fenlei,content,addtime,adder,visit) " +
"values('"+title+"','"+fenlei+"','"+infoContent+"','"+date+"','"+username2+"','0')");
if(flag == Constant.SUCCESS){
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
}
else if(method.equals("upNews")){
String id = request.getParameter("id");
String title = request.getParameter("title");
String fenlei = request.getParameter("fenlei");
String infoContent = request.getParameter("infoContent");
int flag = new NewsBean().exeUp("update news set title='"+title+"',fenlei='"+fenlei+"',content='"+infoContent+"' where id='"+id+"'");
if(flag == Constant.SUCCESS){
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
}
else if(method.equals("delNews")){
String id = request.getParameter("id");
int flag = new NewsBean().exeUp("delete from news where id='"+id+"'");
if(flag == Constant.SUCCESS){
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response);
}
}
else if(method.equals("addPrep")){
String member=(String)session.getAttribute("member");
String sid = request.getParameter("sid");
String title = request.getParameter("title");
String rs = request.getParameter("rs");
String sj = request.getParameter("sj");
String ts = request.getParameter("ts");
String lxr = request.getParameter("lxr");
String lxfs = request.getParameter("lxfs");
int flag = new NewsBean().exeUp("insert into prep(title,rs,sj,ts,lxr,lxfs,addtime,member,zt,ddid) " +
"values('"+title+"','"+rs+"','"+sj+"','"+ts+"','"+lxr+"','"+lxfs+"','"+date+"','"+member+"','未提交','0')");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "预订成功,稍后本站客服人员会与您取得联系。您可以在会员中心查看您的预订记录!");
request.getRequestDispatcher("index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("index.jsp").forward(request, response);
}
}
else if(method.equals("upPrep")){
String member=(String)session.getAttribute("member");
String id = request.getParameter("id");
String rs = request.getParameter("rs");
String sj = request.getParameter("sj");
String ts = request.getParameter("ts");
String lxr = request.getParameter("lxr");
String lxfs = request.getParameter("lxfs");
int flag = new NewsBean().exeUp("update prep set rs='"+rs+"',sj='"+sj+"',ts='"+ts+"',lxr='"+lxr+"'," +
"lxfs='"+lxfs+"' where id='"+id+"'");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("member/prep/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("member/prep/index.jsp").forward(request, response);
}
}
else if(method.equals("delPrep")){
String member=(String)session.getAttribute("member");
String id = request.getParameter("id");
int flag = new NewsBean().exeUp("delete from prep where id='"+id+"'");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("member/prep/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("member/prep/index.jsp").forward(request, response);
}
}
else if(method.equals("addDD")){
String member=(String)session.getAttribute("member");
String fkfs = request.getParameter("fkfs");
String ddid=String.valueOf(System.currentTimeMillis());
String sql="update prep set zt='已提交',ddid='"+ddid+"' where member='"+member+"' and ddid='0'";
//System.out.println(sql);
NewsBean nb=new NewsBean();nb.exeUp(sql);
int flag = nb.exeUp("insert into dd(ddid,member,zt,fkfs,addtime) values('"+ddid+"','"+member+"','未发货','"+fkfs+"','"+date+"')");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("member/prep/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("member/prep/index.jsp").forward(request, response);
}
}
else if(method.equals("fDD")){
String ddid = request.getParameter("ddid");
NewsBean nb=new NewsBean();
int flag = nb.exeUp("update dd set zt='已发货' where ddid='"+ddid+"'");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("admin/prep/prep.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("admin/prep/prep.jsp").forward(request, response);
}
}
else if(method.equals("dDD")){
String ddid = request.getParameter("ddid");
NewsBean nb=new NewsBean();
int flag = nb.exeUp("delete from dd where ddid='"+ddid+"'");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("admin/prep/prep.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("admin/prep/prep.jsp").forward(request, response);
}
}
else if(method.equals("dDD2")){
String ddid = request.getParameter("ddid");
NewsBean nb=new NewsBean();
int flag = nb.exeUp("delete from dd where ddid='"+ddid+"'");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("admin/prep/fh.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("admin/prep/fh.jsp").forward(request, response);
}
}
////////////////////////////////////////////////////////////////////////////////查询统计
else if(method.equals("sDDrq")){
String year=request.getParameter("year");
String month=request.getParameter("month");
String day=request.getParameter("day");
String str=year+"-"+month+"-"+day;
String sql="select * from dd where addtime like '%"+str+"%' ";
request.setAttribute("sql", sql);
request.getRequestDispatcher("admin/prep/s1.jsp").forward(request, response);
}
else if(method.equals("sDDid")){
String ddid=request.getParameter("ddid");
request.setAttribute("ddid", ddid);
request.getRequestDispatcher("admin/prep/s2.jsp").forward(request, response);
}
else if(method.equals("sYye")){
String year=request.getParameter("year");
String month=request.getParameter("month");
String day=request.getParameter("day");
String year2=request.getParameter("year2");
String month2=request.getParameter("month2");
String day2=request.getParameter("day2");
String str=year+"-"+month+"-"+day+" "+"00:00:00";
String str2=year2+"-"+month2+"-"+day2+" "+"23:59:59";
String sql="select sale.dz,prep.* from sale,prep where prep.title=sale.title and prep.addtime>'"+str+"' and prep.addtime<'"+str2+"' order by prep.id desc";
//String sql="select * from prep where addtime>'"+str+"' and addtime<'"+str2+"' ";
request.setAttribute("sql", sql);
request.getRequestDispatcher("admin/prep/s3.jsp").forward(request, response);
}
}catch(Exception e){
e.printStackTrace();
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}

@ -1,2 +0,0 @@
# Resources for parameter 'com.csgw.struts.ApplicationResources'
# Project csgw

@ -1,129 +0,0 @@
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.csgw.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.bean.HzpBean;
import com.util.Constant;
/**
* MyEclipse Struts
* Creation date: 05-05-2010
*
* XDoclet definition:
* @struts.action validate="true"
*/
public class HzpsAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
HttpSession session=request.getSession();
HzpBean tb=new HzpBean();
String method=request.getParameter("method").trim();
///////////////////////////////////////////////////////////////////////商品
if(method.equals("deltrave")){
String id=request.getParameter("id").trim();
int flag = tb.delTrave(id);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
return (mapping.findForward("admin/hzp/index.jsp"));
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
return (mapping.findForward("admin/hzp/index.jsp"));
}
}
else if(method.equals("hotdeltrave")){
String id=request.getParameter("id").trim();
int flag = tb.delTrave(id);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
return (mapping.findForward("admin/hzp/hot.jsp"));
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
return (mapping.findForward("admin/hzp/hot.jsp"));
}
}
else if(method.equals("tejiadeltrave")){
String id=request.getParameter("id").trim();
int flag = tb.delTrave(id);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
return (mapping.findForward("admin/hzp/tejia.jsp"));
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
return (mapping.findForward("admin/hzp/tejia.jsp"));
}
}
else if(method.equals("tuijiandeltrave")){
String id=request.getParameter("id").trim();
int flag = tb.delTrave(id);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
return (mapping.findForward("admin/hzp/tuijian.jsp"));
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
return (mapping.findForward("admin/hzp/tuijian.jsp"));
}
}
else if(method.equals("addType")){
String type=request.getParameter("type").trim();
int flag=tb.addType(type);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
return (mapping.findForward("admin/hzp/type.jsp"));
}
else if(flag==Constant.DEFAULT_ERROR){
request.setAttribute("message", "该分类已存在!");
return (mapping.findForward("admin/hzp/type.jsp"));
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
return (mapping.findForward("admin/hzp/type.jsp"));
}
}
else if(method.equals("delType")){
String id=request.getParameter("id").trim();
int flag=tb.delType(id);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
return (mapping.findForward("admin/hzp/type.jsp"));
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
return (mapping.findForward("admin/hzp/type.jsp"));
}
}
else{
return (mapping.findForward("index.jsp"));
}
}
}
Loading…
Cancel
Save