use of javax.servlet.ServletContext in project ratpack by ratpack.
the class Template method thymeleafTemplate.
public static Template thymeleafTemplate(Map<String, ?> model, String name, String contentType, IFragmentSpec fragmentSpec) {
HttpServletRequest request = new ThymeleafHttpServletRequestAdapter();
HttpServletResponse response = new ThymeleafHttpServletResponseAdapter();
ServletContext servletContext = new ThymeleafServletContextAdapter();
WebContext context = new WebContext(request, response, servletContext);
if (model != null) {
context.setVariables(model);
}
return new Template(name, context, contentType, fragmentSpec);
}
use of javax.servlet.ServletContext in project spring-boot by spring-projects.
the class AbstractServletWebServerFactoryTests method rootServletContextResource.
@Test
public void rootServletContextResource() throws Exception {
AbstractServletWebServerFactory factory = getFactory();
final AtomicReference<URL> rootResource = new AtomicReference<>();
this.webServer = factory.getWebServer(new ServletContextInitializer() {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
try {
rootResource.set(servletContext.getResource("/"));
} catch (MalformedURLException ex) {
throw new ServletException(ex);
}
}
});
this.webServer.start();
assertThat(rootResource.get()).isNotNull();
}
use of javax.servlet.ServletContext in project bigbluebutton by bigbluebutton.
the class HttpTunnelStreamController method getSessionManager.
private ISessionManagerGateway getSessionManager() {
//Get the servlet context
ServletContext ctx = getServletContext();
//Grab a reference to the application context
ApplicationContext appCtx = (ApplicationContext) ctx.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
//Get the bean holding the parameter
ISessionManagerGateway manager = (ISessionManagerGateway) appCtx.getBean("sessionManagerGateway");
if (manager != null) {
System.out.println("****Got the SessionManager context: *****");
}
return manager;
}
use of javax.servlet.ServletContext in project spring-boot by spring-projects.
the class EndpointWebMvcAutoConfigurationTests method onDifferentPortInWebServer.
@Test
public void onDifferentPortInWebServer() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, "management.port=" + ports.get().management);
this.applicationContext.register(RootConfig.class, EndpointConfig.class, DifferentPortConfig.class, BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
ServletContext servletContext = mock(ServletContext.class);
given(servletContext.getInitParameterNames()).willReturn(new Vector<String>().elements());
given(servletContext.getAttributeNames()).willReturn(new Vector<String>().elements());
this.applicationContext.setServletContext(servletContext);
this.applicationContext.refresh();
assertContent("/controller", ports.get().management, null);
assertContent("/endpoint", ports.get().management, null);
}
use of javax.servlet.ServletContext in project eweb4j-framework by laiweiwei.
the class EWebServlet method initContext.
/**
* 初始化
*
* @param req
* @param res
* @throws Exception
*/
private Context initContext(HttpServletRequest request, HttpServletResponse response) throws Exception {
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
Context context = new Context(servletContext, request, response, null, null, null, null);
// 将request的请求参数转到另外一个map中去
Map<String, String[]> qpMap = new HashMap<String, String[]>();
qpMap.putAll(ParamUtil.copyReqParams(context.getRequest()));
context.setQueryParamMap(qpMap);
//将上传的表单元素注入到context中
UploadUtil.handleUpload(context);
return context;
}
Aggregations