01: package test;
02:
03: import java.io.IOException;
04: import java.io.PrintWriter;
05:
06: import javax.servlet.GenericServlet;
07: import javax.servlet.ServletException;
08: import javax.servlet.ServletRequest;
09: import javax.servlet.ServletResponse;
10:
11: public class GetIncludedServlet extends GenericServlet {
12:
13: public void service(ServletRequest request, ServletResponse response)
14: throws ServletException, IOException {
15:
16: String value1 = (String) request
17: .getAttribute("javax.servlet.include.request_uri");
18: String value2 = (String) request
19: .getAttribute("javax.servlet.include.context_path");
20: String value3 = (String) request
21: .getAttribute("javax.servlet.include.servlet_path");
22: String value4 = (String) request
23: .getAttribute("javax.servlet.include.path_info");
24: String value5 = (String) request
25: .getAttribute("javax.servlet.include.query_string");
26: try {
27: PrintWriter writer = response.getWriter();
28:
29: writer.println("<p>javax.servlet.include.request_uri: "
30: + value1);
31: writer.println("<p>javax.servlet.include.context_path: "
32: + value2);
33: writer.println("<P>javax.servlet.include.servlet_path: "
34: + value3);
35: writer.println("<P>javax.servlet.include.path_info: "
36: + value4);
37: writer.println("<P>javax.servlet.include.query_string: "
38: + value5);
39: } catch (IOException e) {
40: e.printStackTrace();
41: }
42: }
43:
44: }
|