use of jakarta.servlet.http.HttpServletResponse in project tomcat by apache.
the class TestExpiresFilter method testUseMajorTypeExpiresConfiguration.
@Test
public void testUseMajorTypeExpiresConfiguration() throws Exception {
HttpServlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/json; charset=iso-8859-1");
response.getWriter().print("Hello world");
}
};
validate(servlet, Integer.valueOf(7 * 60));
}
use of jakarta.servlet.http.HttpServletResponse in project tomcat by apache.
the class TestExpiresFilter method testUseDefaultConfiguration1.
@Test
public void testUseDefaultConfiguration1() throws Exception {
HttpServlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("image/jpeg");
response.getWriter().print("Hello world");
}
};
validate(servlet, Integer.valueOf(1 * 60));
}
use of jakarta.servlet.http.HttpServletResponse in project tomcat by apache.
the class AsyncStockServlet method writeStock.
public void writeStock(AsyncContext actx, Stock stock) throws IOException {
HttpServletResponse response = (HttpServletResponse) actx.getResponse();
PrintWriter writer = response.getWriter();
// make client parsing easier
writer.write("STOCK#");
writer.write(stock.getSymbol());
writer.write("#");
writer.write(stock.getValueAsString());
writer.write("#");
writer.write(stock.getLastChangeAsString());
writer.write("#");
writer.write(String.valueOf(stock.getCnt()));
writer.write("\n");
writer.flush();
response.flushBuffer();
}
use of jakarta.servlet.http.HttpServletResponse in project spring-framework by spring-projects.
the class ResourceUrlEncodingFilterTests method testEncodeUrl.
private void testEncodeUrl(MockHttpServletRequest request, String url, String expected) throws ServletException, IOException {
FilterChain chain = (req, res) -> {
req.setAttribute(ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR, this.urlProvider);
String result = ((HttpServletResponse) res).encodeURL(url);
assertThat(result).isEqualTo(expected);
};
this.filter.doFilter(request, new MockHttpServletResponse(), chain);
}
use of jakarta.servlet.http.HttpServletResponse in project spring-framework by spring-projects.
the class ServletServerHttpAsyncRequestControl method start.
@Override
public void start(long timeout) {
Assert.state(!isCompleted(), "Async processing has already completed");
if (isStarted()) {
return;
}
HttpServletRequest servletRequest = this.request.getServletRequest();
HttpServletResponse servletResponse = this.response.getServletResponse();
this.asyncContext = servletRequest.startAsync(servletRequest, servletResponse);
this.asyncContext.addListener(this);
if (timeout != NO_TIMEOUT_VALUE) {
this.asyncContext.setTimeout(timeout);
}
}
Aggregations