forked from piotrpolak/android-http-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndex.java
64 lines (59 loc) · 3.87 KB
/
Index.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**************************************************
* Android Web Server
* Based on JavaLittleWebServer (2008)
* <p/>
* Copyright (c) Piotr Polak 2008-201
**************************************************/
package example;
import java.io.PrintWriter;
import ro.polak.http.exception.ServletException;
import ro.polak.http.servlet.HttpServletRequest;
import ro.polak.http.servlet.HttpServletResponse;
import ro.polak.http.servlet.HttpServlet;
/**
* Hello page example page
*/
public class Index extends HttpServlet {
@Override
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException {
PrintWriter printWriter = response.getWriter();
printWriter.println("<h1>Hello World!</h1>");
printWriter.println("<p>Demo servlet page.</p>");
printWriter.println("<p>Character encoding: " + request.getCharacterEncoding() + "</p>");
printWriter.println("<p>Content length: " + request.getContentLength() + "</p>");
printWriter.println("<p>Local addr: " + request.getLocalAddr() + "</p>");
printWriter.println("<p>Local port: " + request.getLocalPort() + "</p>");
printWriter.println("<p>Local port: " + request.getLocalName() + "</p>");
printWriter.println("<p>Remote addr: " + request.getRemoteAddr() + "</p>");
printWriter.println("<p>Remote host: " + request.getRemoteHost() + "</p>");
printWriter.println("<p>Remote port: " + request.getRemotePort() + "</p>");
printWriter.println("<p>Request method: " + request.getMethod() + "</p>");
printWriter.println("<p>Request protocol: " + request.getProtocol() + "</p>");
printWriter.println("<p>Request scheme: " + request.getScheme() + "</p>");
printWriter.println("<p>Request method: " + request.getMethod() + "</p>");
printWriter.println("<p>Request server name: " + request.getServerName() + "</p>");
printWriter.println("<p>Request server port: " + request.getServerPort() + "</p>");
printWriter.println("<p>Request is secure: " + request.isSecure() + "</p>");
printWriter.println("<p>Request URI: " + request.getRequestURI() + "</p>");
printWriter.println("<p>Request URL: " + request.getRequestURL() + "</p>");
printWriter.println("<p>Auth type: " + request.getAuthType() + "</p>");
printWriter.println("<p>Context path: " + request.getContextPath() + "</p>");
printWriter.println("<p>Path translated: " + request.getPathTranslated() + "</p>");
printWriter.println("<p>Path info: " + request.getPathInfo() + "</p>");
printWriter.println("<p>Remote user: " + request.getRemoteUser() + "</p>");
printWriter.println("<p>User principal: " + request.getUserPrincipal() + "</p>");
printWriter.println("<p>Is requested session id from cookie: " + request.isRequestedSessionIdFromCookie() + "</p>");
printWriter.println("<p>Is requested session id from URL: " + request.isRequestedSessionIdFromURL() + "</p>");
printWriter.println("<p>Is requested session id valid " + request.isRequestedSessionIdValid() + "</p>");
printWriter.println("<ul>");
printWriter.println("<li><a href='Session.dhtml'>Session example</a></li>");
printWriter.println("<li><a href='Cookies.dhtml'>Cookies example</a></li>");
printWriter.println("<li><a href='Forbidden.dhtml'>Forbidden page example</a></li>");
printWriter.println("<li><a href='NotFound.dhtml'>Not found page example</a></li>");
printWriter.println("<li><a href='InternalServerError.dhtml'>Internal server error page example</a></li>");
printWriter.println("<li><a href='Streaming.dhtml'>Streaming</a></li>");
printWriter.println("<li><a href='Chunked.dhtml'>Chunked</a></li>");
printWriter.println("<li><a href='ChunkedWithDelay.dhtml'>Chunked with a delay</a></li>");
printWriter.println("</ul>");
}
}