1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.util;
16
17 import java.io.IOException;
18
19 import javax.servlet.ServletException;
20 import javax.servlet.http.HttpServlet;
21 import javax.servlet.http.HttpServletRequest;
22 import javax.servlet.http.HttpServletResponse;
23
24
25
26
27
28
29 public abstract class ServletContentWrapper extends HttpServlet {
30
31 private final String content_;
32
33
34
35
36
37
38 public ServletContentWrapper(final String content) {
39 content_ = content;
40 }
41
42
43
44
45 @Override
46 protected void doGet(final HttpServletRequest request, final HttpServletResponse response)
47 throws ServletException, IOException {
48 response.setContentType(MimeType.TEXT_HTML);
49 response.getWriter().write(content_);
50 }
51
52
53
54
55 @Override
56 protected void doPost(final HttpServletRequest request, final HttpServletResponse response)
57 throws ServletException, IOException {
58 doGet(request, response);
59 }
60
61
62
63
64
65 protected String getContent() {
66 return content_;
67 }
68
69
70
71
72
73 protected int getContentLength() {
74 return content_.length();
75 }
76 }