📄 globalstatus.java
字号:
/*
Copyright 2006 Christian Gross http://www.devspace.com
From the book Ajax Patterns and Best Practices
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package devspace.ajax.persistentcommunications;
import devspace.ajax.permutations.*;
import javax.servlet.http.*;
import devspace.testDrivenDevelopment.tracer.*;
import java.io.*;
import javax.servlet.*;
public class GlobalStatus extends HttpHandlerBase {
static String _buffer;
static VersionTracker _version = new VersionTracker(10000);
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
if (_version.getNew(req)) {
synchronized( _version) {
PrintWriter output = resp.getWriter();
output.write("Content (" + _buffer + ") Version (" +
_version.getVersionNumber() + ")");
}
_version.writeVersion( resp);
GenerateOutput.Write("GlobalStatus.DoGet", "Writing something changed");
}
else {
resp.setStatus( 408, "No change");
GenerateOutput.Write("GlobalStatus.DoGet", "Writing nothing changed");
}
}
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
ServletInputStream input = req.getInputStream();
byte[] bytearray = new byte[ req.getContentLength()];
input.read( bytearray);
_buffer = new String( bytearray).toString();
_version.increment();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -