out.println("<h3>" + title + "</h3>");
out.println("<table border=0>");
- Enumeration e = request.getHeaderNames();
+ Enumeration<String> e = request.getHeaderNames();
while (e.hasMoreElements()) {
- String headerName = (String)e.nextElement();
+ String headerName = e.nextElement();
String headerValue = request.getHeader(headerName);
out.println("<tr><td bgcolor=\"#CCCCCC\">");
out.println(HTMLFilter.filter(headerName));
out.println("<body>");
// img stuff not req'd for source code html showing
- // relative links everywhere!
+ // relative links everywhere!
// XXX
// making these absolute till we work out the
// addition of a PathInfo issue
-
+
out.println("<a href=\"../sessions.html\">");
out.println("<img src=\"../images/code.gif\" height=24 " +
"width=24 align=right border=0 alt=\"view code\"></a>");
out.println("<P>");
out.println(rb.getString("sessions.data") + "<br>");
- Enumeration names = session.getAttributeNames();
+ Enumeration<String> names = session.getAttributeNames();
while (names.hasMoreElements()) {
- String name = (String) names.nextElement();
+ String name = names.nextElement();
String value = session.getAttribute(name).toString();
out.println(HTMLFilter.filter(name) + " = "
+ HTMLFilter.filter(value) + "<br>");
out.println("<P>");
out.print("<form action=\"");
- out.print(response.encodeURL("SessionExample"));
+ out.print(response.encodeURL("SessionExample"));
out.print("\" ");
out.println("method=POST>");
out.println(rb.getString("sessions.dataname"));
out.println("<P>GET based form:<br>");
out.print("<form action=\"");
- out.print(response.encodeURL("SessionExample"));
+ out.print(response.encodeURL("SessionExample"));
out.print("\" ");
out.println("method=GET>");
out.println(rb.getString("sessions.dataname"));
out.println("</form>");
out.print("<p><a href=\"");
- out.print(response.encodeURL("SessionExample?dataname=foo&datavalue=bar"));
- out.println("\" >URL encoded </a>");
-
+ out.print(response.encodeURL("SessionExample?dataname=foo&datavalue=bar"));
+ out.println("\" >URL encoded </a>");
+
out.println("</body>");
out.println("</html>");
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 cal;
public class Entry {
- String hour;
- String description;
- String color;
+ String hour;
+ String description;
+ String color;
- public Entry (String hour) {
- this.hour = hour;
- this.description = "";
+ public Entry(String hour) {
+ this.hour = hour;
+ this.description = "";
- }
-
- public String getHour () {
- return this.hour;
- }
-
- public String getColor () {
- if (description.equals("")) return "lightblue";
- else return "red";
- }
-
- public String getDescription () {
- if (description.equals("")) return "None";
- else return this.description;
- }
-
- public void setDescription (String descr) {
- description = descr;
- }
-
-}
+ }
+ public String getHour() {
+ return this.hour;
+ }
+ public String getColor() {
+ if (description.equals("")) {
+ return "lightblue";
+ }
+ return "red";
+ }
+ public String getDescription() {
+ if (description.equals("")) {
+ return "None";
+ }
+ return this.description;
+ }
+ public void setDescription(String descr) {
+ description = descr;
+ }
+}
response.sendRedirect("post.jsp");
event.close();
return;
- } else {
- String nickname = (String) request.getSession(true).getAttribute("nickname");
- String message = request.getParameter("message");
- messageSender.send(nickname, message);
- response.sendRedirect("post.jsp");
- event.close();
- return;
- }
- } else {
- if (request.getSession(true).getAttribute("nickname") == null) {
- // Redirect to "login"
- log("Redirect to login for session: " + request.getSession(true).getId());
- response.sendRedirect("login.jsp");
- event.close();
- return;
}
+ String nickname = (String) request.getSession(true).getAttribute("nickname");
+ String message = request.getParameter("message");
+ messageSender.send(nickname, message);
+ response.sendRedirect("post.jsp");
+ event.close();
+ return;
+ }
+ if (request.getSession(true).getAttribute("nickname") == null) {
+ // Redirect to "login"
+ log("Redirect to login for session: " + request.getSession(true).getId());
+ response.sendRedirect("login.jsp");
+ event.close();
+ return;
}
begin(event, request, response);
} else if (event.getEventType() == CometEvent.EventType.ERROR) {
}
protected void begin(CometEvent event, HttpServletRequest request, HttpServletResponse response)
- throws IOException, ServletException {
+ throws IOException {
log("Begin for session: " + request.getSession(true).getId());
PrintWriter writer = response.getWriter();
}
protected void end(CometEvent event, HttpServletRequest request, HttpServletResponse response)
- throws IOException, ServletException {
+ throws IOException {
log("End for session: " + request.getSession(true).getId());
synchronized(connections) {
connections.remove(response);
}
protected void error(CometEvent event, HttpServletRequest request, HttpServletResponse response)
- throws IOException, ServletException {
+ throws IOException {
log("Error for session: " + request.getSession(true).getId());
synchronized(connections) {
connections.remove(response);
}
protected void read(CometEvent event, HttpServletRequest request, HttpServletResponse response)
- throws IOException, ServletException {
+ throws IOException {
InputStream is = request.getInputStream();
byte[] buf = new byte[512];
while (is.available() > 0) {
protected ArrayList<String> messages = new ArrayList<String>();
public MessageSender() {
+ // Default contructor
}
public void stop() {
private String color2 = background;
private String hint = "no";
private int attempts = 0;
- private int intval = 0;
+ private int intval = 0;
private boolean tookHints = false;
public void processRequest() {
- // background = "yellow";
- // foreground = "red";
+ // background = "yellow";
+ // foreground = "red";
- if (! color1.equals(foreground)) {
- if (color1.equalsIgnoreCase("black") ||
- color1.equalsIgnoreCase("cyan")) {
- background = color1;
- }
- }
+ if (! color1.equals(foreground)) {
+ if (color1.equalsIgnoreCase("black") ||
+ color1.equalsIgnoreCase("cyan")) {
+ background = color1;
+ }
+ }
- if (! color2.equals(background)) {
- if (color2.equalsIgnoreCase("black") ||
- color2.equalsIgnoreCase("cyan")) {
- foreground = color2;
- }
- }
+ if (! color2.equals(background)) {
+ if (color2.equalsIgnoreCase("black") ||
+ color2.equalsIgnoreCase("cyan")) {
+ foreground = color2;
+ }
+ }
- attempts++;
+ attempts++;
}
public void setColor2(String x) {
- color2 = x;
+ color2 = x;
}
public void setColor1(String x) {
- color1 = x;
+ color1 = x;
}
public void setAction(String x) {
- if (!tookHints)
- tookHints = x.equalsIgnoreCase("Hint");
- hint = x;
+ if (!tookHints)
+ tookHints = x.equalsIgnoreCase("Hint");
+ hint = x;
}
public String getColor2() {
- return background;
+ return background;
}
public String getColor1() {
- return foreground;
+ return foreground;
}
public int getAttempts() {
- return attempts;
+ return attempts;
}
public boolean getHint() {
- return hint.equalsIgnoreCase("Hint");
+ return hint.equalsIgnoreCase("Hint");
}
public boolean getSuccess() {
- if (background.equalsIgnoreCase("black") ||
- background.equalsIgnoreCase("cyan")) {
-
- if (foreground.equalsIgnoreCase("black") ||
- foreground.equalsIgnoreCase("cyan"))
- return true;
- else
- return false;
- }
-
- return false;
+ if (background.equalsIgnoreCase("black") ||
+ background.equalsIgnoreCase("cyan")) {
+
+ if (foreground.equalsIgnoreCase("black") ||
+ foreground.equalsIgnoreCase("cyan")) {
+ return true;
+ }
+ return false;
+ }
+
+ return false;
}
public boolean getHintTaken() {
- return tookHints;
+ return tookHints;
}
public void reset() {
- foreground = "red";
- background = "yellow";
+ foreground = "red";
+ background = "yellow";
}
public void setIntval(int value) {
- intval = value;
- }
+ intval = value;
+ }
public int getIntval() {
- return intval;
- }
+ return intval;
+ }
}
return;
}
- Enumeration e =
+ Enumeration<String> e =
((HttpServletRequest)request).getHeaders("Accept-Encoding");
while (e.hasMoreElements()) {
- String name = (String)e.nextElement();
+ String name = e.nextElement();
if (name.indexOf("gzip") != -1) {
if (debug > 0) {
System.out.println("supports compression");
}
chain.doFilter(request, response);
return;
- } else {
- if (response instanceof HttpServletResponse) {
- CompressionServletResponseWrapper wrappedResponse =
- new CompressionServletResponseWrapper((HttpServletResponse)response);
- wrappedResponse.setDebugLevel(debug);
- wrappedResponse.setCompressionThreshold(compressionThreshold);
- if (debug > 0) {
- System.out.println("doFilter gets called with compression");
- }
- try {
- chain.doFilter(request, wrappedResponse);
- } finally {
- wrappedResponse.finishResponse();
- }
- return;
+ }
+
+ if (response instanceof HttpServletResponse) {
+ CompressionServletResponseWrapper wrappedResponse =
+ new CompressionServletResponseWrapper((HttpServletResponse)response);
+ wrappedResponse.setDebugLevel(debug);
+ wrappedResponse.setCompressionThreshold(compressionThreshold);
+ if (debug > 0) {
+ System.out.println("doFilter gets called with compression");
}
+ try {
+ chain.doFilter(request, wrappedResponse);
+ } finally {
+ wrappedResponse.finishResponse();
+ }
+ return;
}
}
ServletOutputStream out = response.getOutputStream();
response.setContentType("text/plain");
- Enumeration e = request.getHeaders("Accept-Encoding");
+ Enumeration<String> e = request.getHeaders("Accept-Encoding");
while (e.hasMoreElements()) {
- String name = (String)e.nextElement();
+ String name = e.nextElement();
out.println(name);
if (name.indexOf("gzip") != -1) {
out.println("gzip supported -- able to compress");
stream.close();
}
} catch (IOException e) {
+ // Ignore
}
}
public void setContentLength(int length) {
+ // Don't, as compression will change it
}
}
}
- // Default implementations for BodyTag methods as well
- // just in case a tag decides to implement BodyTag.
public void doInitBody() throws JspException {
+ // Default implementations for BodyTag methods as well
+ // just in case a tag decides to implement BodyTag.
}
public int doAfterBody() throws JspException {
if (i == 3) {
bodyOut.writeOut(bodyOut.getEnclosingWriter());
return SKIP_BODY;
- } else
- pageContext.setAttribute("member", atts[i]);
+ }
+
+ pageContext.setAttribute("member", atts[i]);
i++;
return EVAL_BODY_BUFFERED;
} catch (IOException ex) {
writer.println(" contentType=" + request.getContentType());
writer.println(" locale=" + request.getLocale());
writer.print(" locales=");
- Enumeration locales = request.getLocales();
+ Enumeration<Locale> locales = request.getLocales();
boolean first = true;
while (locales.hasMoreElements()) {
- Locale locale = (Locale) locales.nextElement();
+ Locale locale = locales.nextElement();
if (first)
first = false;
else
writer.print(locale.toString());
}
writer.println();
- Enumeration names = request.getParameterNames();
+ Enumeration<String> names = request.getParameterNames();
while (names.hasMoreElements()) {
- String name = (String) names.nextElement();
+ String name = names.nextElement();
writer.print(" parameter=" + name + "=");
String values[] = request.getParameterValues(name);
for (int i = 0; i < values.length; i++) {
}
names = hrequest.getHeaderNames();
while (names.hasMoreElements()) {
- String name = (String) names.nextElement();
+ String name = names.nextElement();
String value = hrequest.getHeader(name);
writer.println(" header=" + name + "=" + value);
}
*/
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
- throws IOException, ServletException {
+ throws IOException, ServletException {
// Conditionally select and set the character encoding to be used
if (ignore || (request.getCharacterEncoding() == null)) {
request.setCharacterEncoding(encoding);
}
- // Pass control on to the next filter
+ // Pass control on to the next filter
chain.doFilter(request, response);
}
*/
public void init(FilterConfig filterConfig) throws ServletException {
- this.filterConfig = filterConfig;
+ this.filterConfig = filterConfig;
this.encoding = filterConfig.getInitParameter("encoding");
String value = filterConfig.getInitParameter("ignore");
if (value == null)