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

📄 bookstoreservlet.java

📁 初期JAVA学习非常有用的资料。帮助深入了解API。特别是Applet。
💻 JAVA
字号:
/*Copyright (c) 1998 Sun Microsystems, Inc. All Rights Reserved.This software is the confidential and proprietary information of SunMicrosystems, Inc. ("Confidential Information").  You shall notdisclose such Confidential Information and shall use it only inaccordance with the terms of the license agreement you entered intowith Sun.SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THESOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THEIMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULARPURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGESSUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTINGTHIS SOFTWARE OR ITS DERIVATIVES.CopyrightVersion 1.0*/import java.io.*;import javax.servlet.*;import javax.servlet.http.*;/** * An HTTP Servlet that overrides the service method to return a * simple web page. */public class BookStoreServlet extends HttpServlet {     public void service (HttpServletRequest request,                         HttpServletResponse response)        throws ServletException, IOException    {        // Get the dispatcher; it gets the main page to the user        RequestDispatcher dispatcher =            getServletContext().getRequestDispatcher(                "/bookstore/bookstore.html");        if (dispatcher == null) {System.out.println("There was no dispatcher");            // No dispatcher means the html file could not be found.            response.sendError(response.SC_NO_CONTENT);        } else {System.out.println("There is a dispatcher");            // Get or start a new session for this user            HttpSession session = request.getSession();            // Send the user the bookstore's opening page            dispatcher.forward(request, response);        }    }    public String getServletInfo() {        return "The BookStore servlet returns the main web page " +               "for Duke's Bookstore.";    }}

⌨️ 快捷键说明

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