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

📄 librariancheckincontroller.java

📁 一个关于图书馆的服务器的管理程序
💻 JAVA
字号:
import java.io.IOException;import java.net.URLEncoder;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 library.Book;import library.Librarian;import library.Member;import library.Library;import library.LibraryBook;/** * Class <b>LibrarianCheckinController</b> contains  * the servlet controller functionality for processing * book check ins by librarians. *  * * @author CTE * @version 1.0 */public class LibrarianCheckinController extends Controller {    /**     * LibrarianCheckinController doPost method.  This is can be called     * by <b>Controller</b> superclass' doGet() method.     * @param req HttpServletRequest servlet request object     * @param res HttpServletResponse servlet response object     * @throws ServletException     * @throws IOException     */    public void doPost (HttpServletRequest req, HttpServletResponse res)	throws ServletException, IOException {	// Get the current HttpSession.	HttpSession session = req.getSession();		// Get the Librarian bean from the session.	Librarian librarian = (Librarian) session.getAttribute("librarian");		// Create a book object. 	Book book = null;		Library library = null;	// Create a new instance of the Library object.        try {	    library = new Library();	} catch( Exception e ) {	    sendErrorRedirect(req, res, e);	}		// Get the bookid parameter.	int bookID = (req.getParameter("bookID") == null) ? 0 : Integer.parseInt(req.getParameter("bookID"));		// Initialize the book object and place it into the session.	try {	    book = LibraryBook.getBook(bookID);	    session.setAttribute( "book", book );	} catch( Exception e ) {	    sendErrorRedirect(req, res, e);	}			// If the book is null, it is not in the database.  If it is not null,	// check it back in.	if (book != null) {	    try {		// Check the book in.		if (library.checkInBook(bookID)) {		    res.sendRedirect("/library/entrycomplete.jsp?action=checkedin");		} else {		    res.sendRedirect("/library/librarianaccess.jsp");		}	    } catch (Exception e) {		// Send the exception to the standard error page.		sendErrorRedirect(req, res, e);	    }	} else {	    // This book did not exist. Set the error in the HttpSession.	    session.setAttribute( "checkinbook", "This book does not exist" );	    	    // Send the user back to the librarianaccess page.	    res.sendRedirect("/library/librarianaccess.jsp");	}    }}

⌨️ 快捷键说明

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