Vinay Vishal | 5717147 | 2018-09-18 20:22:00 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. |
| 3 | * |
| 4 | * This program and the accompanying materials are made available under the |
| 5 | * terms of the Eclipse Public License v. 2.0, which is available at |
| 6 | * http://www.eclipse.org/legal/epl-2.0. |
| 7 | * |
| 8 | * This Source Code may also be made available under the following Secondary |
| 9 | * Licenses when the conditions for such availability set forth in the |
| 10 | * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, |
| 11 | * version 2 with the GNU Classpath Exception, which is available at |
| 12 | * https://www.gnu.org/software/classpath/license.html. |
| 13 | * |
| 14 | * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 |
| 15 | */ |
| 16 | |
| 17 | package test; |
| 18 | |
| 19 | import java.io.*; |
| 20 | import java.net.*; |
| 21 | import java.util.*; |
| 22 | import javax.servlet.*; |
| 23 | import javax.servlet.http.*; |
| 24 | |
| 25 | import java.net.URL; |
| 26 | import java.util.ArrayList; |
| 27 | import java.util.HashMap; |
| 28 | |
| 29 | import javax.naming.*; |
| 30 | import javax.sql.*; |
| 31 | import java.sql.*; |
| 32 | |
| 33 | public class ServletTest extends HttpServlet{ |
| 34 | |
| 35 | private ServletContext context; |
| 36 | private static String status = "ApplicationDispatcher::PASS"; |
| 37 | |
| 38 | public void init(ServletConfig config) throws ServletException { |
| 39 | super.init(config); |
| 40 | System.out.println("[Servlet.init]"); |
| 41 | |
| 42 | try{ |
| 43 | RequestDispatcher requestD = |
| 44 | getServletContext().getRequestDispatcher("/test.jsp"); |
| 45 | |
| 46 | if ( requestD == null){ |
| 47 | status = "ApplicationDispatcher::FAIL"; |
| 48 | } |
| 49 | System.out.println("[Servlet.RequestDispatcher: " + requestD + "]"); |
| 50 | } catch (Throwable t){ |
| 51 | status = "ApplicationDispatcher::FAIL"; |
| 52 | } |
| 53 | System.out.println("status: " + status); |
| 54 | } |
| 55 | |
| 56 | public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
| 57 | System.out.println("[Servlet.doGet]"); |
| 58 | doPost(request, response); |
| 59 | } |
| 60 | |
| 61 | public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
| 62 | System.out.println("[Servlet.doPost]"); |
| 63 | |
| 64 | PrintWriter out = response.getWriter(); |
| 65 | response.setContentType("text/html"); |
| 66 | out.println(status); |
| 67 | } |
| 68 | |
| 69 | } |