⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addchatroomdo.java

📁 一个bbs论坛系统
💻 JAVA
字号:
package com.lovo.servlet;

import java.io.IOException;
import java.sql.SQLException;

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 com.lovo.factory.BOFactory;
import com.lovo.po.ChatroomPO;
import com.lovo.vo.ChatroomVO;

public class AddChatroomDO extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request,response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		HttpSession session = request.getSession();
		
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		response.setCharacterEncoding("utf-8");
		
		RequestDispatcher rd = request.getRequestDispatcher("error.jsp");
		String name = request.getParameter("name");
		String maxusernumStr = request.getParameter("maxusernum");
		int maxusernum = 10;
		if(maxusernumStr.matches("\\d+")) {
			maxusernum = Integer.parseInt(maxusernumStr);
		}
		ChatroomVO chat = new ChatroomVO();
		chat.setName(name);
		chat.setMaxUserNum(maxusernum);
		
		try {
			BOFactory.getChatroomBOInstance().addChatroom(chat);
			response.sendRedirect("QueryChatroomDO");
		} catch (SQLException e) {
			e.printStackTrace();
			rd.forward(request, response);
			return;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -