提交 9d35faf1 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 9ce12a7c
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
javac=javac javac=javac
benchmark.drivers.dir=D\:/data/java benchmark.drivers.dir=D\:/data/java
version.name.maven=1.0.20070617 version.name.maven=1.0.20070617
path.servlet.jar=C\:/data/classpath/servlet-api-2.3.jar path.servlet.jar=C\:/data/classpath/servlet-api.jar
jdk=1.4 jdk=1.4
...@@ -273,7 +273,7 @@ ...@@ -273,7 +273,7 @@
</target> </target>
<target name="warConsole" depends="compileServlet, jar"> <target name="warConsole" depends="compileServlet, jar">
<war destfile="bin/h2console.war" webxml="src/tools/WEB-INF/web.xml"> <war destfile="bin/h2console.war" webxml="src/tools/WEB-INF/web.xml" basedir="src/tools/WEB-INF" includes="console.html">
<lib file="bin/h2.jar" /> <lib file="bin/h2.jar" />
</war> </war>
</target> </target>
......
...@@ -37,9 +37,13 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch. ...@@ -37,9 +37,13 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
<h3>Version 1.0 (Current)</h3> <h3>Version 1.0 (Current)</h3>
<h3>Version 1.0 / TODO (Build TODO)</h3><ul> <h3>Version 1.0 / TODO (Build TODO)</h3><ul>
<li>Deleting database files didn't work for Windows if the database was on the root directory of a drive. <li>The H2 Console can now be run as a standalone web application, or it can be embedded as a servlet into any
existing web application. To build the 'H2 Console' web application, execute 'ant warConsole'.
See src/tools/org/h2/server/web and src/tools/WEB-INF for details.
</li><li>Deleting database files didn't work for Windows if the database was on the root directory of a drive.
</li><li>The Polish translation is available. Thanks a lot to Tomek! </li><li>The Polish translation is available. Thanks a lot to Tomek!
</li><li>Windows service: the CLASSPATH was not included when starting the service. Fixed. </li><li>Windows service: the CLASSPATH was not included when starting the service. Fixed.
</li>
</ul> </ul>
<h3>Version 1.0 / 2007-06-17 (Build 50)</h3><ul> <h3>Version 1.0 / 2007-06-17 (Build 50)</h3><ul>
......
...@@ -314,48 +314,15 @@ bad if they don't get closed). ...@@ -314,48 +314,15 @@ bad if they don't get closed).
The server mode is similar, but it allows you to run the server in another process. The server mode is similar, but it allows you to run the server in another process.
<h3>Using a Servlet Listener to Start and Stop a Database</h3> <h3>Using a Servlet Listener to Start and Stop a Database</h3>
Add the following to the web.xml file (after context-param and before filter): Add the h2.jar file your web application, and
add the following snippet to your web.xml file (after context-param and before filter):
<pre> <pre>
&lt;listener> &lt;listener>
&lt;listener-class>db.Starter&lt;/listener-class> &lt;listener-class>org.h2.server.web.DbStarter&lt;/listener-class>
&lt;/listener> &lt;/listener>
</pre> </pre>
Add the following Starter class: For details on how to access the database, see the code DbStarter.java
<pre>
package org.h2.tools.servlet;
import javax.servlet.*;
import java.sql.*;
public class DbStarter implements ServletContextListener {
private Connection conn;
public void contextInitialized(ServletContextEvent servletContextEvent) {
try {
Class.forName("org.h2.Driver");
// You can also get the setting from a context-param in web.xml:
// ServletContext servletContext = servletContextEvent.getServletContext();
// String url = servletContext.getInitParameter("db.url");
conn = DriverManager.getConnection("jdbc:h2:test", "sa", "");
} catch (Exception e) {
e.printStackTrace();
}
}
public Connection getConnection() {
return conn;
}
public void contextDestroyed(ServletContextEvent servletContextEvent) {
try {
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
</pre>
<br /><a name="csv"></a> <br /><a name="csv"></a>
<h2>CSV (Comma Separated Values) Support</h2> <h2>CSV (Comma Separated Values) Support</h2>
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html> <html>
<head> <head>
<title>H2 Console</title> <title>H2 Console</title>
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=console/"> <META HTTP-EQUIV="Refresh" CONTENT="0; URL=console/" />
</head> </head>
<body> <body>
<a href="console/">H2 Console</a> <a href="console/">H2 Console</a>
......
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<web-app xmlns="http://java.sun.com/xml/ns/javaee" <web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
...@@ -28,13 +32,16 @@ ...@@ -28,13 +32,16 @@
<welcome-file>/console.html</welcome-file> <welcome-file>/console.html</welcome-file>
</welcome-file-list> </welcome-file-list>
<security-constraint>
<!-- Enable the following section when you want basic authentication -->
<!-- <!--
<security-constraint>
<web-resource-collection> <web-resource-collection>
<web-resource-name>H2 Console</web-resource-name> <web-resource-name>H2 Console</web-resource-name>
<url-pattern>/console/*</url-pattern> <url-pattern>/console/*</url-pattern>
</web-resource-collection> </web-resource-collection>
-->
<auth-constraint> <auth-constraint>
<role-name>admin</role-name> <role-name>admin</role-name>
</auth-constraint> </auth-constraint>
...@@ -49,4 +56,6 @@ ...@@ -49,4 +56,6 @@
<role-name>admin</role-name> <role-name>admin</role-name>
</security-role> </security-role>
-->
</web-app> </web-app>
/*
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.server.web; package org.h2.server.web;
import javax.servlet.*; import javax.servlet.*;
...@@ -9,7 +13,7 @@ public class DbStarter implements ServletContextListener { ...@@ -9,7 +13,7 @@ public class DbStarter implements ServletContextListener {
public void contextInitialized(ServletContextEvent servletContextEvent) { public void contextInitialized(ServletContextEvent servletContextEvent) {
try { try {
Class.forName("org.h2.Driver"); org.h2.Driver.load();
// You can also get the setting from a context-param in web.xml: // You can also get the setting from a context-param in web.xml:
ServletContext servletContext = servletContextEvent.getServletContext(); ServletContext servletContext = servletContextEvent.getServletContext();
// String url = servletContext.getInitParameter("db.url"); // String url = servletContext.getInitParameter("db.url");
......
...@@ -26,13 +26,10 @@ public class WebServlet extends HttpServlet { ...@@ -26,13 +26,10 @@ public class WebServlet extends HttpServlet {
private static final long serialVersionUID = 9171446624885086692L; private static final long serialVersionUID = 9171446624885086692L;
private WebServer server; private WebServer server;
private void testLog(String s) { private int todoRefactorRemoveDuplicateCode;
int todoRefactorSimplify; private int todoRemoveSystem_out;
int todoRemoveTestLogMethod; private int todoTestWithTomcat;
int todoTestWithTomcat; private int todoTestWithJetty;
int todoTestWithJetty;
System.out.println(s);
}
public void init() throws ServletException { public void init() throws ServletException {
ServletConfig config = getServletConfig(); ServletConfig config = getServletConfig();
...@@ -77,7 +74,6 @@ public class WebServlet extends HttpServlet { ...@@ -77,7 +74,6 @@ public class WebServlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String file = req.getPathInfo(); String file = req.getPathInfo();
trace("get " + file);
if(file == null) { if(file == null) {
resp.sendRedirect(req.getRequestURI() + "/"); resp.sendRedirect(req.getRequestURI() + "/");
return; return;
...@@ -101,7 +97,7 @@ public class WebServlet extends HttpServlet { ...@@ -101,7 +97,7 @@ public class WebServlet extends HttpServlet {
en = req.getParameterNames(); en = req.getParameterNames();
while(en.hasMoreElements()) { while(en.hasMoreElements()) {
String name = (String) en.nextElement(); String name = (String) en.nextElement();
String value = (String) req.getParameter(name); String value = req.getParameter(name);
attributes.put(name, value); attributes.put(name, value);
} }
WebSession session = null; WebSession session = null;
...@@ -109,7 +105,6 @@ public class WebServlet extends HttpServlet { ...@@ -109,7 +105,6 @@ public class WebServlet extends HttpServlet {
if(sessionId != null) { if(sessionId != null) {
session = server.getSession(sessionId); session = server.getSession(sessionId);
} }
int todoSupportCache;
String mimeType; String mimeType;
boolean cache; boolean cache;
int index = file.lastIndexOf('.'); int index = file.lastIndexOf('.');
...@@ -129,7 +124,7 @@ public class WebServlet extends HttpServlet { ...@@ -129,7 +124,7 @@ public class WebServlet extends HttpServlet {
cache=true; cache=true;
mimeType = "text/css"; mimeType = "text/css";
} else if(suffix.equals("html") || suffix.equals("do") || suffix.equals("jsp")) { } else if(suffix.equals("html") || suffix.equals("do") || suffix.equals("jsp")) {
cache=false; cache = false;
mimeType = "text/html"; mimeType = "text/html";
if (session == null) { if (session == null) {
int todoTest; int todoTest;
...@@ -140,7 +135,7 @@ public class WebServlet extends HttpServlet { ...@@ -140,7 +135,7 @@ public class WebServlet extends HttpServlet {
} }
} }
} else if(suffix.equals("js")) { } else if(suffix.equals("js")) {
cache=true; cache = true;
mimeType = "text/javascript"; mimeType = "text/javascript";
} else { } else {
cache = false; cache = false;
...@@ -151,7 +146,6 @@ public class WebServlet extends HttpServlet { ...@@ -151,7 +146,6 @@ public class WebServlet extends HttpServlet {
server.trace("mimeType="+mimeType); server.trace("mimeType="+mimeType);
// parseHeader(); // parseHeader();
String ifModifiedSince = req.getHeader("if-modified-since"); String ifModifiedSince = req.getHeader("if-modified-since");
testLog("@ifmod=" + ifModifiedSince);
server.trace(file); server.trace(file);
WebThread app = new WebThread(null, server); WebThread app = new WebThread(null, server);
...@@ -160,8 +154,8 @@ public class WebServlet extends HttpServlet { ...@@ -160,8 +154,8 @@ public class WebServlet extends HttpServlet {
file = app.process(file); file = app.process(file);
} }
if(cache && server.getStartDateTime().equals(ifModifiedSince)) { if(cache && server.getStartDateTime().equals(ifModifiedSince)) {
resp.sendError(HttpServletResponse.SC_NOT_MODIFIED); resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
bytes = null; return;
} else { } else {
bytes = server.getFile(file); bytes = server.getFile(file);
} }
...@@ -196,11 +190,6 @@ public class WebServlet extends HttpServlet { ...@@ -196,11 +190,6 @@ public class WebServlet extends HttpServlet {
} }
} }
private void trace(String s) {
int todo;
System.out.println("## " + s);
}
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
doGet(req, resp); doGet(req, resp);
} }
......
...@@ -458,6 +458,7 @@ maxvalue samooha dbrewster minvalue darwin follow graphics typically ...@@ -458,6 +458,7 @@ maxvalue samooha dbrewster minvalue darwin follow graphics typically
netscape mywebpage javaplayer fuse davidlbarron helps player appfuse awt netscape mywebpage javaplayer fuse davidlbarron helps player appfuse awt
gridwidth editable pressed entered awt east toolkit insets exited grid mouse west resizable popup focusable bag anchor gridwidth editable pressed entered awt east toolkit insets exited grid mouse west resizable popup focusable bag anchor
headless headless
polish javaee resp xsi instances tomek realm xsd appended auth polski
### check those again: ### check those again:
populate slowly xacon inser maxbqualsize counter regards attaching official xatest populate slowly xacon inser maxbqualsize counter regards attaching official xatest
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论