-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathServletTest.java
More file actions
39 lines (32 loc) · 1.33 KB
/
ServletTest.java
File metadata and controls
39 lines (32 loc) · 1.33 KB
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
package de.binfalse.martin;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author martin scharm
*
*/
public class ServletTest
extends HttpServlet
{
protected void doGet (HttpServletRequest request, HttpServletResponse response)
throws ServletException,
IOException
{
response.setContentType ("text/html");
request.setCharacterEncoding ("UTF-8");
PrintWriter out = response.getWriter ();
out.println ("new File (\".\").getAbsolutePath () => " + new File (".").getAbsolutePath ());
out.println ("request.getPathInfo () => " + request.getPathInfo ());
out.println ("request.getPathTranslated () => " + request.getPathTranslated ());
out.println ("request.getContextPath () => " + request.getContextPath ());
out.println ("request.getRealPath (request.getServletPath ()) => " + request.getRealPath (request.getServletPath ()));
out.println ("request.getServletPath () => " + request.getServletPath ());
out.println ("getServletContext ().getContextPath () => " + getServletContext ().getContextPath ());
out.println ("getServletContext ().getRealPath (\".\") => " + getServletContext ().getRealPath ("."));
}
}