// // ======================================================================== // Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. // // This program and the accompanying materials are made available under the // terms of the Eclipse Public License v. 2.0 which is available at // https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 // which is available at https://www.apache.org/licenses/LICENSE-2.0. // // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 // ======================================================================== // package org.example; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import jakarta.servlet.ServletConfig; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.eclipse.jetty.util.StringUtil; /** * Rego Servlet - tests being accessed from servlet 3.0 programmatic * configuration. */ public class RegTest extends HttpServlet { @Override public void init(ServletConfig config) throws ServletException { super.init(config); } @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } @Override public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); PrintWriter pout = null; try { pout = response.getWriter(); } catch (IllegalStateException e) { pout = new PrintWriter(new OutputStreamWriter(response.getOutputStream(), "UTF-8")); } try { pout.write("\n
\n"); pout.write("| getMethod: | "); pout.write("" + notag(request.getMethod()) + " | "); pout.write("
|---|---|
| getContentLength: | "); pout.write("" + Integer.toString(request.getContentLength()) + " | "); pout.write("
| getContentType: | "); pout.write("" + notag(request.getContentType()) + " | "); pout.write("
| getRequestURI: | "); pout.write("" + notag(request.getRequestURI()) + " | "); pout.write("
| getRequestURL: | "); pout.write("" + notag(request.getRequestURL().toString()) + " | "); pout.write("
| getContextPath: | "); pout.write("" + request.getContextPath() + " | "); pout.write("
| getServletPath: | "); pout.write("" + notag(request.getServletPath()) + " | "); pout.write("
| getPathInfo: | "); pout.write("" + notag(request.getPathInfo()) + " | "); pout.write("
| getPathTranslated: | "); pout.write("" + notag(request.getPathTranslated()) + " | "); pout.write("
| getQueryString: | "); pout.write("" + notag(request.getQueryString()) + " | "); pout.write("
| getProtocol: | "); pout.write("" + request.getProtocol() + " | "); pout.write("
| getScheme: | "); pout.write("" + request.getScheme() + " | "); pout.write("
| getServerName: | "); pout.write("" + notag(request.getServerName()) + " | "); pout.write("
| getServerPort: | "); pout.write("" + Integer.toString(request.getServerPort()) + " | "); pout.write("
| getLocalName: | "); pout.write("" + request.getLocalName() + " | "); pout.write("
| getLocalAddr: | "); pout.write("" + request.getLocalAddr() + " | "); pout.write("
| getLocalPort: | "); pout.write("" + Integer.toString(request.getLocalPort()) + " | "); pout.write("
| getRemoteUser: | "); pout.write("" + request.getRemoteUser() + " | "); pout.write("
| getUserPrincipal: | "); pout.write("" + request.getUserPrincipal() + " | "); pout.write("
| getRemoteAddr: | "); pout.write("" + request.getRemoteAddr() + " | "); pout.write("
| getRemoteHost: | "); pout.write("" + request.getRemoteHost() + " | "); pout.write("
| getRemotePort: | "); pout.write("" + request.getRemotePort() + " | "); pout.write("
| getRequestedSessionId: | "); pout.write("" + request.getRequestedSessionId() + " | "); pout.write("
| isSecure(): | "); pout.write("" + request.isSecure() + " | "); pout.write("
| isUserInRole(admin): | "); pout.write("" + request.isUserInRole("admin") + " | "); pout.write("