blob: a08b8c09204713b2a5dd8c74ccd3f5dbedba7423 [file] [log] [blame]
Vinay Vishal57171472018-09-18 20:22:00 +05301/*
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
17package test;
18
19import java.io.*;
20import java.net.*;
21import java.util.*;
22import javax.servlet.*;
23import javax.servlet.http.*;
24
25import java.net.URL;
26import java.util.ArrayList;
27import java.util.HashMap;
28
29import javax.naming.*;
30import javax.sql.*;
31import java.sql.*;
32
33public 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}