use of org.h2.server.web.WebServlet in project h2database by h2database.
the class TestWeb method testServlet.
private void testServlet() throws Exception {
WebServlet servlet = new WebServlet();
final HashMap<String, String> configMap = new HashMap<>();
configMap.put("ifExists", "");
configMap.put("", "");
configMap.put("", "");
configMap.put("", "");
ServletConfig config = new ServletConfig() {
@Override
public String getServletName() {
return "H2Console";
}
@Override
public Enumeration<String> getInitParameterNames() {
return new Vector<>(configMap.keySet()).elements();
}
@Override
public String getInitParameter(String name) {
return configMap.get(name);
}
@Override
public ServletContext getServletContext() {
return null;
}
};
servlet.init(config);
TestHttpServletRequest request = new TestHttpServletRequest();
request.setPathInfo("/");
TestHttpServletResponse response = new TestHttpServletResponse();
TestServletOutputStream out = new TestServletOutputStream();
response.setServletOutputStream(out);
servlet.doGet(request, response);
assertContains(out.toString(), "location.href = 'login.jsp");
servlet.destroy();
}
use of org.h2.server.web.WebServlet in project spring-boot by spring-projects.
the class H2ConsoleAutoConfiguration method h2Console.
@Bean
public ServletRegistrationBean<WebServlet> h2Console() {
String path = this.properties.getPath();
String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*");
ServletRegistrationBean<WebServlet> registration = new ServletRegistrationBean<>(new WebServlet(), urlMapping);
H2ConsoleProperties.Settings settings = this.properties.getSettings();
if (settings.isTrace()) {
registration.addInitParameter("trace", "");
}
if (settings.isWebAllowOthers()) {
registration.addInitParameter("webAllowOthers", "");
}
return registration;
}
use of org.h2.server.web.WebServlet in project felix by apache.
the class H2Activator method start.
@Override
public void start(BundleContext context) throws Exception {
ds = new JdbcDataSource();
ds.setURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE");
Dictionary<String, String> props = new Hashtable<String, String>();
props.put("dataSourceName", "test");
context.registerService(DataSource.class.getName(), ds, props);
loadData(ds);
// Register the H2 console servlet
Dictionary<String, String> servletProps = new Hashtable<String, String>();
servletProps.put("alias", "/h2");
servletProps.put("init.webAllowOthers", "true");
context.registerService(Servlet.class.getName(), new WebServlet(), servletProps);
}
use of org.h2.server.web.WebServlet in project gs-spring-security-3.2 by rwinch.
the class H2Initializer method onStartup.
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
ServletRegistration.Dynamic dynamic = servletContext.addServlet("h2", new WebServlet());
dynamic.addMapping("/h2/*");
}
Aggregations