【文章內(nèi)容簡介】
ervlet. 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 { (text/html)。 String name=(name)。 String pwd=(pwd)。 //userBean user = new userBean(name,pwd)。 user test=new user()。 try { userBean user = (name)。 if (user!=null){ if ((())){ library bookinfo=new library()。//Dao涓殑library ListlibraryBean list=()。 ().setAttribute(list,list)。 // (() + InfoServlet)。 (InfoServlet).forward(request, response)。 }else{ ()。 } }else{ ()。 } } catch (Exception e) { // TODO Autogenerated catch block ()。 } } /** * 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 { (text/html)。 doGet(request,response)。 } /** * Initialization of the servlet. br * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here }}登錄后主頁面 圖書管理員登錄系統(tǒng)后可以進(jìn)行圖書管理,圖書管理模塊包含了圖書增、刪、改、查管理和圖書管理參數(shù)等子功能。下面分別進(jìn)行介紹: 圖書的增、刪、改、查管理截圖如下所示: 1) 添加圖書信息2)刪除圖書信息 3)以圖書類應(yīng)編號為主鍵,修改圖書信息:4)輸入書名,查詢圖書信息:示例代碼如下所示:1) 增加代碼: package servlet。import 。import 。import 。import 。import 。import 。import 。import 。public class AddBookServlet extends HttpServlet { /** * Constructor of the object. */ public AddBookServlet() { super()。 } /** * Destruction of the servlet. br */ public void destroy() { ()。 // Just puts destroy string in log // Put your code here } public void doPost(HttpServletRequest request, HttpServletResponse response) { library library = new library()。 libraryBean book = new libraryBean((pubname), (bookname), ((typeid)), (author), ((storage)), ((borrownum)))。 try { (book)。 (InfoServlet).forward(request, response)。 } catch (ClassNotFoundException e) { // TODO Autogenerated catch block ()。 } catch (Exception e) { ()。 } } /** * Initialization of the servlet. br * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here }}2) 刪除代碼: package servlet。import 。import 。import 。import 。import 。import 。import 。import 。public class DeleteServlet extends HttpServlet { /** * Constructor of the object. */ public DeleteServlet() { super()。 } /** * Destruction of the servlet. br */ public void 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 { library library = new library()。 int i = ((typeid))。 try { (i)。 (InfoServlet).forward(request, response)。 } catch (Exception e) { // TODO Autogenerated catch block ()。 } } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // TODO Autogenerated method stub (req, resp)。 } /** * Initialization of the servlet. br * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here }}3) 修改代碼: package servlet。import 。import 。import 。import 。import 。import 。import 。import 。@SuppressWarnings(serial)public class UpDateServlet extends HttpServlet {