/* $$ Clover has instrumented this file $$ */// Copyright 2004 The Apache Software Foundation
//
// 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 org.apache.tapestry.request;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.IRender;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.Tapestry;
import org.apache.tapestry.multipart.DefaultMultipartDecoder;
import org.apache.tapestry.multipart.IMultipartDecoder;
import org.apache.tapestry.spec.IApplicationSpecification;
/**
* This class encapsulates all the relevant data for one request cycle of an
* {@link ApplicationServlet}. This includes:
* <ul>
* <li>{@link HttpServletRequest}
* <li>{@link HttpServletResponse}
* <li>{@link HttpSession}
* <li>{@link javax.servlet.http.HttpServlet}
* </ul>
* <p>It also provides methods for:
* <ul>
* <li>Retrieving the request parameters (even if a file upload is involved)
* <li>Getting, setting and removing request attributes
* <li>Forwarding requests
* <li>Redirecting requests
* <li>Getting and setting Cookies
* <li>Intepreting the request path info
* <li>Writing an HTML description of the <code>RequestContext</code> (for debugging).
* </ul>
*
*
* <p>
* If some cases, it is necesary to provide an implementation of
* {@link IRequestDecoder} (often, due to a firewall).
* If the application specifification
* provides an extension named
* <code>org.apache.tapestry.request-decoder</code>
* then it will be used, instead of a default decoder.
*
* <p>This class is not a component, but does implement {@link IRender}. When asked to render
* (perhaps as the delegate of a {@link org.apache.tapestry.components.Delegator} component}
* it simply invokes {@link #write(IMarkupWriter)} to display all debugging output.
*
* <p>This class is derived from the original class
* <code>com.primix.servlet.RequestContext</code>,
* part of the <b>ServletUtils</b> framework available from
* <a href="http://www.gjt.org/servlets/JCVSlet/list/gjt/com/primix/servlet">The Giant
* Java Tree</a>.
*
*
* @author Howard Lewis Ship
*
**/
public class RequestContext implements IRender
{public static com.cortexeb.tools.clover.d __CLOVER_240_0 = com.cortexeb.tools.clover.aq.getRecorder(new char[] {67,58,92,119,111,114,107,115,112,97,99,101,92,106,97,107,97,114,116,97,45,116,97,112,101,115,116,114,121,92,102,114,97,109,101,119,111,114,107,92,116,97,114,103,101,116,92,99,108,111,118,101,114,45,100,98},1097439627296L);
/** @since 2.2 **/
private static class DefaultRequestDecoder implements IRequestDecoder
{
public DecodedRequest decodeRequest(HttpServletRequest request)
{try { __CLOVER_240_0.M[3190]++;
__CLOVER_240_0.S[13461]++;DecodedRequest result = new DecodedRequest();
__CLOVER_240_0.S[13462]++;result.setRequestURI(request.getRequestURI());
__CLOVER_240_0.S[13463]++;result.setScheme(request.getScheme());
__CLOVER_240_0.S[13464]++;result.setServerName(request.getServerName());
__CLOVER_240_0.S[13465]++;result.setServerPort(request.getServerPort());
__CLOVER_240_0.S[13466]++;return result;
} finally { }}
}
private static final Log LOG = LogFactory.getLog(RequestContext.class);
private HttpSession _session;
private HttpServletRequest _request;
private HttpServletResponse _response;
private HttpServlet _servlet;
private DecodedRequest _decodedRequest;
private IMultipartDecoder _decoder;
private boolean _decoded;
private IApplicationSpecification _specification;
/**
* A mapping of the cookies available in the request.
*
**/
private Map _cookieMap;
/**
* Used during {@link #write(IMarkupWriter)}.
*
**/
private boolean _evenRow;
/**
* Creates a <code>RequestContext</code> from its components.
*
**/
public RequestContext(
HttpServlet servlet,
HttpServletRequest request,
HttpServletResponse response,
IApplicationSpecification specification)
throws IOException
{try { __CLOVER_240_0.M[3191]++;
__CLOVER_240_0.S[13467]++;_servlet = servlet;
__CLOVER_240_0.S[13468]++;_request = request;
__CLOVER_240_0.S[13469]++;_response = response;
__CLOVER_240_0.S[13470]++;_specification = specification;
// All three parameters may be null if created from
// AbstractEngine.cleanupEngine().
__CLOVER_240_0.S[13471]++;if ((((_request != null && DefaultMultipartDecoder.isMultipartRequest(request)) && (++__CLOVER_240_0.CT[2258] != 0)) || (++__CLOVER_240_0.CF[2258] == 0))){
{
__CLOVER_240_0.S[13472]++;IMultipartDecoder decoder = obtainMultipartDecoder(servlet, request);
__CLOVER_240_0.S[13473]++;setDecoder(decoder);
}}
} finally { }}
/**
* Invoked from the constructor to create a {@link DefaultMultipartDecoder} instance.
* Applications with specific upload needs may need to override this to
* provide a subclass instance instead. The caller will invoke
* {@link IMultipartDecoder#decode(HttpServletRequest)} on the
* returned object.
*
* <p>
* This implementation checks for application extension
* {@link Tapestry#MULTIPART_DECODER_EXTENSION_NAME}. If that is not
* defined, a shared instance of {@link DefaultMultipartDecoder}
* is returned.
*
*
* @see ApplicationServlet#createRequestContext(HttpServletRequest, HttpServletResponse)
* @since 3.0
*
**/
protected IMultipartDecoder obtainMultipartDecoder(
HttpServlet servlet,
HttpServletRequest request)
throws IOException
{try { __CLOVER_240_0.M[3192]++;
__CLOVER_240_0.S[13474]++;if ((((_specification.checkExtension(Tapestry.MULTIPART_DECODER_EXTENSION_NAME)) && (++__CLOVER_240_0.CT[2259] != 0)) || (++__CLOVER_240_0.CF[2259] == 0))){
__CLOVER_240_0.S[13475]++;return (IMultipartDecoder) _specification.getExtension(
Tapestry.MULTIPART_DECODER_EXTENSION_NAME,
IMultipartDecoder.class);}
__CLOVER_240_0.S[13476]++;return DefaultMultipartDecoder.getSharedInstance();
} finally { }}
/**
* Adds a simple {@link Cookie}. To set a Cookie with attributes,
* use {@link #addCookie(Cookie)}.
*
**/
public void addCookie(String name, String value)
{try { __CLOVER_240_0.M[3193]++;
__CLOVER_240_0.S[13477]++;addCookie(new Cookie(name, value));
} finally { }}
/**
* Adds a {@link Cookie} to the response. Once added, the
* Cookie will also be available to {@link #getCookie(String)} method.
*
* <p>Cookies should only be added <em>before</em> invoking
* {@link HttpServletResponse#getWriter()}..
*
**/
public void addCookie(Cookie cookie)
{try { __CLOVER_240_0.M[3194]++;
__CLOVER_240_0.S[13478]++;if ((((LOG.isDebugEnabled()) && (++__CLOVER_240_0.CT[2260] != 0)) || (++__CLOVER_240_0.CF[2260] == 0))){
__CLOVER_240_0.S[13479]++;LOG.debug("Adding cookie " + cookie);}
__CLOVER_240_0.S[13480]++;_response.addCookie(cookie);
__CLOVER_240_0.S[13481]++;if ((((_cookieMap == null) && (++__CLOVER_240_0.CT[2261] != 0)) || (++__CLOVER_240_0.CF[2261] == 0))){
__CLOVER_240_0.S[13482]++;readCookieMap();}
__CLOVER_240_0.S[13483]++;_cookieMap.put(cookie.getName(), cookie);
} finally { }}
private void datePair(IMarkupWriter writer, String name, long value)
{try { __CLOVER_240_0.M[3195]++;
__CLOVER_240_0.S[13484]++;pair(writer, name, new Date(value));
} finally { }}
/** @since 2.2 **/
private DecodedRequest getDecodedRequest()
{try { __CLOVER_240_0.M[3196]++;
__CLOVER_240_0.S[13485]++;if ((((_decodedRequest != null) && (++__CLOVER_240_0.CT[2262] != 0)) || (++__CLOVER_240_0.CF[2262] == 0))){
__CLOVER_240_0.S[13486]++;return _decodedRequest;}
__CLOVER_240_0.S[13487]++;IRequestDecoder decoder = null;
__CLOVER_240_0.S[13488]++;if ((((!_specification.checkExtension(Tapestry.REQUEST_DECODER_EXTENSION_NAME)) && (++__CLOVER_240_0.CT[2263] != 0)) || (++__CLOVER_240_0.CF[2263] == 0))){
__CLOVER_240_0.S[13489]++;decoder = new DefaultRequestDecoder();}
else{
__CLOVER_240_0.S[13490]++;decoder =
(IRequestDecoder) _specification.getExtension(
Tapestry.REQUEST_DECODER_EXTENSION_NAME,
IRequestDecoder.class);}
__CLOVER_240_0.S[13491]++;_decodedRequest = decoder.decodeRequest(_request);
__CLOVER_240_0.S[13492]++;return _decodedRequest;
} finally { }}
/**
*
* Returns the actual scheme, possibly decoded from the request.
*
* @see IRequestDecoder
* @see javax.servlet.ServletRequest#getScheme()
* @since 2.2
*
**/
public String getScheme()
{try { __CLOVER_240_0.M[3197]++;
__CLOVER_240_0.S[13493]++;return getDecodedRequest().getScheme();
} finally { }}
/**
*
* Returns the actual server name, possibly decoded from the request.
*
* @see IRequestDecoder
* @see javax.servlet.ServletRequest#getServerName()
* @since 2.2
*
**/
public String getServerName()
{try { __CLOVER_240_0.M[3198]++;
__CLOVER_240_0.S[13494]++;return getDecodedRequest().getServerName();
} finally { }}
/**
*
* Returns the actual server port, possibly decoded from the request.
*
* @see IRequestDecoder
* @see javax.servlet.ServletRequest#getServerPort()
* @since 2.2
*
**/
public int getServerPort()
{try { __CLOVER_240_0.M[3199]++;
__CLOVER_240_0.S[13495]++;return getDecodedRequest().getServerPort();
} finally { }}
/**
*
* Returns the actual request URI, possibly decoded from the request.
*
* @see IRequestDecoder
* @see HttpServletRequest#getRequestURI()
* @since 2.2
*
**/
public String getRequestURI()
{try { __CLOVER_240_0.M[3200]++;
__CLOVER_240_0.S[13496]++;return getDecodedRequest().getRequestURI();
} finally { }}
/**
* Builds an absolute URL from the given URI, using the {@link HttpServletRequest}
* as the source for scheme, server name and port.
*
* @see #getAbsoluteURL(String, String, String, int)
*
**/
public String x_getAbsoluteURL(String URI)
{try { __CLOVER_240_0.M[3201]++;
__CLOVER_240_0.S[13497]++;String scheme = getScheme();
__CLOVER_240_0.S[13498]++;String server = getServerName();
__CLOVER_240_0.S[13499]++;int port = getServerPort();
// Keep things simple ... port 80 is accepted as the
// standard port for http so it can be ommitted.
// Some of the Tomcat code indicates that port 443 is the default
// for https, and that needs to be researched.
__CLOVER_240_0.S[13500]++;if ((((scheme.equals("http") && port == 80) && (++__CLOVER_240_0.CT[2264] != 0)) || (++__CLOVER_240_0.CF[2264] == 0))){
__CLOVER_240_0.S[13501]++;port = 0;}
__CLOVER_240_0.S[13502]++;return getAbsoluteURL(URI, scheme, server, port);
} finally { }}
/**
* Does some easy checks to turn a path (or URI) into an absolute URL. We assume
* <ul>
* <li>The presense of a colon means the path is complete already (any other colons
* in the URI portion should have been converted to %3A).
*
* <li>A leading pair of forward slashes means the path is simply missing
* the scheme.
* <li>Otherwise, we assemble the scheme, server, port (if non-zero) and the URI
* as given.
* </ul>
*
**/
public String getAbsoluteURL(String URI, String scheme, String server, int port)
{try { __CLOVER_240_0.M[3202]++;
__CLOVER_240_0.S[13503]++;StringBuffer buffer = new StringBuffer();
// Though, really, what does a leading colon with no scheme before it
// mean?
__CLOVER_240_0.S[13504]++;if ((((URI.indexOf(':') >= 0) && (++__CLOVER_240_0.CT[2265] != 0)) || (++__CLOVER_240_0.CF[2265] == 0))){
__CLOVER_240_0.S[13505]++;return URI;}
// Should check the length here, first.
__CLOVER_240_0.S[13506]++;if ((((URI.substring(0, 1).equals("//")) && (++__CLOVER_240_0.CT[2266] != 0)) || (++__CLOVER_240_0.CF[2266] == 0))){
{
__CLOVER_240_0.S[13507]++;buffer.append(scheme);
__CLOVER_240_0.S[13508]++;buffer.append(':');
__CLOVER_240_0.S[13509]++;buffer.append(URI);
__CLOVER_240_0.S[13510]++;return buffer.toString();
}}
__CLOVER_240_0.S[13511]++;buffer.append(scheme);
__CLOVER_240_0.S[13512]++;buffer.append("://");
__CLOVER_240_0.S[13513]++;buffer.append(server);
__CLOVER_240_0.S[13514]++;if ((((port > 0) && (++__CLOVER_240_0.CT[2267] != 0)) || (++__CLOVER_240_0.CF[2267] == 0))){
{
__CLOVER_240_0.S[13515]++;buffer.append(':');
__CLOVER_240_0.S[13516]++;buffer.append(port);
}}
__CLOVER_240_0.S[13517]++;if ((((URI.charAt(0) != '/') && (++__CLOVER_240_0.CT[2268] != 0)) || (++__CLOVER_240_0.CF[2268] == 0))){
__CLOVER_240_0.S[13518]++;buffer.append('/');}
__CLOVER_240_0.S[13519]++;buffer.append(URI);
__CLOVER_240_0.S[13520]++;return buffer.toString();
} finally { }}
/**
* Gets a named {@link Cookie}.
*
* @param name The name of the Cookie.
* @return The Cookie, or null if no Cookie with that
* name exists.
*
**/
public Cookie getCookie(String name)
{try { __CLOVER_240_0.M[3203]++;
__CLOVER_240_0.S[13521]++;if ((((_cookieMap == null) && (++__CLOVER_240_0.CT[2269] != 0)) || (++__CLOVER_240_0.CF[2269] == 0))){
__CLOVER_240_0.S[13522]++;readCookieMap();}
__CLOVER_240_0.S[13523]++;return (Cookie) _cookieMap.get(name);
} finally { }}
/**
* Reads the named {@link Cookie} and returns its value (if it exists), or
* null if it does not exist.
**/
public String getCookieValue(String name)
{try { __CLOVER_240_0.M[3204]++;
__CLOVER_240_0.S[13524]++;Cookie cookie;
__CLOVER_240_0.S[13525]++;cookie = getCookie(name);
__CLOVER_240_0.S[13526]++;if ((((cookie == null) && (++__CLOVER_240_0.CT[2270] != 0)) || (++__CLOVER_240_0.CF[2270] == 0))){
__CLOVER_240_0.S[13527]++;return null;}
__CLOVER_240_0.S[13528]++;return cookie.getValue();
} finally { }}
/**
* Returns the named parameter from the {@link HttpServletRequest}.
*
* <p>Use {@link #getParameters(String)} for parameters that may
* include multiple values.
*
* <p>This is the preferred way to obtain parameter values (rather than
* obtaining the {@link HttpServletRequest} itself). For form/multipart-data
* encoded requests, this method will still work.
*
**/
public String getParameter(String name)
{try { __CLOVER_240_0.M[3205]++;
__CLOVER_240_0.S[13529]++;IMultipartDecoder decoder = getDecoder();
__CLOVER_240_0.S[13530]++;if ((((decoder != null) && (++__CLOVER_240_0.CT[2271] != 0)) || (++__CLOVER_240_0.CF[2271] == 0))){
__CLOVER_240_0.S[13531]++;return decoder.getString(_request, name);}
__CLOVER_240_0.S[13532]++;return _request.getParameter(name);
} finally { }}
/**
* Convienience method for getting a {@link HttpServletRequest} attribute.
*
* @since 2.3
*
**/
public Object getAttribute(String name)
{try { __CLOVER_240_0.M[3206]++;
__CLOVER_240_0.S[13533]++;return _request.getAttribute(name);
} finally { }}
/**
* For parameters that are, or are possibly, multi-valued, this
* method returns all the values as an array of Strings.
*
* @see #getParameter(String)
*
**/
public String[] getParameters(String name)
{try { __CLOVER_240_0.M[3207]++;
// Note: this may not be quite how we want it to work; we'll have to see.
__CLOVER_240_0.S[13534]++;IMultipartDecoder decoder = getDecoder();
__CLOVER_240_0.S[13535]++;if ((((decoder != null) && (++__CLOVER_240_0.CT[2272] != 0)) || (++__CLOVER_240_0.CF[2272] == 0))){
__CLOVER_240_0.S[13536]++;return decoder.getStrings(_request, name);}
__CLOVER_240_0.S[13537]++;return _request.getParameterValues(name);
} finally { }}
/**
* Returns the named {@link IUploadFile}, if it exists, or null if it doesn't.
* Uploads require an encoding of <code>multipart/form-data</code>
* (this is specified in the
* form's enctype attribute). If the encoding type
* is not so, or if no upload matches the name, then this method returns null.
*
**/
public IUploadFile getUploadFile(String name)
{try { __CLOVER_240_0.M[3208]++;
__CLOVER_240_0.S[13538]++;IMultipartDecoder decoder = getDecoder();
__CLOVER_240_0.S[13539]++;if ((((decoder == null) && (++__CLOVER_240_0.CT[2273] != 0)) || (++__CLOVER_240_0.CF[2273] == 0))){
__CLOVER_240_0.S[13540]++;return null;}
__CLOVER_240_0.S[13541]++;return decoder.getUploadFile(_request, name);
} finally { }}
/**
* Invoked at the end of the request cycle to cleanup and temporary resources.
* This is chained to the {@link DefaultMultipartDecoder}, if there is one.
*
* @since 2.0.1
**/
public void cleanup()
{try { __CLOVER_240_0.M[3209]++;
__CLOVER_240_0.S[13542]++;if ((((_decoder != null) && (++__CLOVER_240_0.CT[2274] != 0)) || (++__CLOVER_240_0.CF[2274] == 0))){
__CLOVER_240_0.S[13543]++;_decoder.cleanup(_request);}
} finally { }}
/**
* Returns the request which initiated the current request cycle. Note that
* the methods {@link #getParameter(String)} and {@link #getParameters(String)}
* should be used, rather than obtaining parameters directly from the request
* (since the RequestContext handles the differences between normal and multipart/form
* requests).
*
**/
public HttpServletRequest getRequest()
{try { __CLOVER_240_0.M[3210]++;
__CLOVER_240_0.S[13544]++;return _request;
} finally { }}
public HttpServletResponse getResponse()
{try { __CLOVER_240_0.M[3211]++;
__CLOVER_240_0.S[13545]++;return _response;
} finally { }}
private String getRowClass()
{try { __CLOVER_240_0.M[3212]++;
__CLOVER_240_0.S[13546]++;String result;
__CLOVER_240_0.S[13547]++;result = (((_evenRow ) && (++__CLOVER_240_0.CT[2275] != 0)) || (++__CLOVER_240_0.CF[2275] == 0))? "even" : "odd";
__CLOVER_240_0.S[13548]++;_evenRow = !_evenRow;
__CLOVER_240_0.S[13549]++;return result;
} finally { }}
public HttpServlet getServlet()
{try { __CLOVER_240_0.M[3213]++;
__CLOVER_240_0.S[13550]++;return _servlet;
} finally { }}
/**
* Returns the {@link HttpSession}, if necessary, invoking
* {@link HttpServletRequest#getSession(boolean)}. However,
* this method will <em>not</em> create a session.
*
**/
public HttpSession getSession()
{try { __CLOVER_240_0.M[3214]++;
__CLOVER_240_0.S[13551]++;if ((((_session == null) && (++__CLOVER_240_0.CT[2276] != 0)) || (++__CLOVER_240_0.CF[2276] == 0))){
__CLOVER_240_0.S[13552]++;_session = _request.getSession(false);}
__CLOVER_240_0.S[13553]++;return _session;
} finally { }}
/**
* Like {@link #getSession()}, but forces the creation of
* the {@link HttpSession}, if necessary.
*
**/
public HttpSession createSession()
{try { __CLOVER_240_0.M[3215]++;
__CLOVER_240_0.S[13554]++;if ((((_session == null) && (++__CLOVER_240_0.CT[2277] != 0)) || (++__CLOVER_240_0.CF[2277] == 0))){
{
__CLOVER_240_0.S[13555]++;if ((((LOG.isDebugEnabled()) && (++__CLOVER_240_0.CT[2278] != 0)) || (++__CLOVER_240_0.CF[2278] == 0))){
__CLOVER_240_0.S[13556]++;LOG.debug("Creating HttpSession");}
__CLOVER_240_0.S[13557]++;_session = _request.getSession(true);
}}
__CLOVER_240_0.S[13558]++;return _session;
} finally { }}
private void header(IMarkupWriter writer, String valueName, String dataName)
{try { __CLOVER_240_0.M[3216]++;
__CLOVER_240_0.S[13559]++;writer.begin("tr");
__CLOVER_240_0.S[13560]++;writer.attribute("class", "request-context-header");
__CLOVER_240_0.S[13561]++;writer.begin("th");
__CLOVER_240_0.S[13562]++;writer.print(valueName);
__CLOVER_240_0.S[13563]++;writer.end();
__CLOVER_240_0.S[13564]++;writer.begin("th");
__CLOVER_240_0.S[13565]++;writer.print(dataName);
__CLOVER_240_0.S[13566]++;writer.end("tr");
__CLOVER_240_0.S[13567]++;_evenRow = true;
} finally { }}
private void object(IMarkupWriter writer, String objectName)
{try { __CLOVER_240_0.M[3217]++;
__CLOVER_240_0.S[13568]++;writer.begin("span");
__CLOVER_240_0.S[13569]++;writer.attribute("class", "request-context-object");
__CLOVER_240_0.S[13570]++;writer.print(objectName);
__CLOVER_240_0.S[13571]++;writer.end();
} finally { }}
private void pair(IMarkupWriter writer, String name, int value)
{try { __CLOVER_240_0.M[3218]++;
__CLOVER_240_0.S[13572]++;pair(writer, name, Integer.toString(value));
} finally { }}
private void pair(IMarkupWriter writer, String name, Object value)
{try { __CLOVER_240_0.M[3219]++;
__CLOVER_240_0.S[13573]++;if ((((value == null) && (++__CLOVER_240_0.CT[2279] != 0)) || (++__CLOVER_240_0.CF[2279] == 0))){
__CLOVER_240_0.S[13574]++;return;}
__CLOVER_240_0.S[13575]++;pair(writer, name, value.toString());
} finally { }}
private void pair(IMarkupWriter writer, String name, String value)
{try { __CLOVER_240_0.M[3220]++;
__CLOVER_240_0.S[13576]++;if ((((value == null) && (++__CLOVER_240_0.CT[2280] != 0)) || (++__CLOVER_240_0.CF[2280] == 0))){
__CLOVER_240_0.S[13577]++;return;}
__CLOVER_240_0.S[13578]++;if ((((value.length() == 0) && (++__CLOVER_240_0.CT[2281] != 0)) || (++__CLOVER_240_0.CF[2281] == 0))){
__CLOVER_240_0.S[13579]++;return;}
__CLOVER_240_0.S[13580]++;writer.begin("tr");
__CLOVER_240_0.S[13581]++;writer.attribute("class", getRowClass());
__CLOVER_240_0.S[13582]++;writer.begin("th");
__CLOVER_240_0.S[13583]++;writer.print(name);
__CLOVER_240_0.S[13584]++;writer.end();
__CLOVER_240_0.S[13585]++;writer.begin("td");
__CLOVER_240_0.S[13586]++;writer.print(value);
__CLOVER_240_0.S[13587]++;writer.end("tr");
__CLOVER_240_0.S[13588]++;writer.println();
} finally { }}
private void pair(IMarkupWriter writer, String name, boolean value)
{try { __CLOVER_240_0.M[3221]++;
__CLOVER_240_0.S[13589]++;pair(writer, name, (((value ) && (++__CLOVER_240_0.CT[2282] != 0)) || (++__CLOVER_240_0.CF[2282] == 0))? "yes" : "no");
} finally { }}
private void readCookieMap()
{try { __CLOVER_240_0.M[3222]++;
__CLOVER_240_0.S[13590]++;_cookieMap = new HashMap();
__CLOVER_240_0.S[13591]++;Cookie[] cookies = _request.getCookies();
__CLOVER_240_0.S[13592]++;if ((((cookies != null) && (++__CLOVER_240_0.CT[2283] != 0)) || (++__CLOVER_240_0.CF[2283] == 0))){
__CLOVER_240_0.S[13593]++;for (int i = 0; (((i < cookies.length) && (++__CLOVER_240_0.CT[2284] != 0)) || (++__CLOVER_240_0.CF[2284] == 0)); i++){
__CLOVER_240_0.S[13594]++;_cookieMap.put(cookies[i].getName(), cookies[i]);}}
} finally { }}
private void section(IMarkupWriter writer, String sectionName)
{try { __CLOVER_240_0.M[3223]++;
__CLOVER_240_0.S[13595]++;writer.begin("tr");
__CLOVER_240_0.S[13596]++;writer.attribute("class", "request-context-section");
__CLOVER_240_0.S[13597]++;writer.begin("th");
__CLOVER_240_0.S[13598]++;writer.attribute("colspan", 2);
__CLOVER_240_0.S[13599]++;writer.print(sectionName);
__CLOVER_240_0.S[13600]++;writer.end("tr");
} finally { }}
private List getSorted(Enumeration e)
{try { __CLOVER_240_0.M[3224]++;
__CLOVER_240_0.S[13601]++;List result = new ArrayList();
// JDK 1.4 includes a helper method in Collections for
// this; but we want 1.2 compatibility for the
// forseable future.
__CLOVER_240_0.S[13602]++;while ((((e.hasMoreElements()) && (++__CLOVER_240_0.CT[2285] != 0)) || (++__CLOVER_240_0.CF[2285] == 0))){
__CLOVER_240_0.S[13603]++;result.add(e.nextElement());}
__CLOVER_240_0.S[13604]++;Collections.sort(result);
__CLOVER_240_0.S[13605]++;return result;
} finally { }}
/**
* Writes the state of the context to the writer, typically for inclusion
* in a HTML page returned to the user. This is useful
* when debugging. The Inspector uses this as well.
*
**/
public void write(IMarkupWriter writer)
{try { __CLOVER_240_0.M[3225]++;
// Create a box around all of this stuff ...
__CLOVER_240_0.S[13606]++;writer.begin("table");
__CLOVER_240_0.S[13607]++;writer.attribute("class", "request-context-border");
__CLOVER_240_0.S[13608]++;writer.begin("tr");
__CLOVER_240_0.S[13609]++;writer.begin("td");
// Get the session, if it exists, and display it.
__CLOVER_240_0.S[13610]++;HttpSession session = getSession();
__CLOVER_240_0.S[13611]++;if ((((session != null) && (++__CLOVER_240_0.CT[2286] != 0)) || (++__CLOVER_240_0.CF[2286] == 0))){
{
__CLOVER_240_0.S[13612]++;object(writer, "Session");
__CLOVER_240_0.S[13613]++;writer.begin("table");
__CLOVER_240_0.S[13614]++;writer.attribute("class", "request-context-object");
__CLOVER_240_0.S[13615]++;section(writer, "Properties");
__CLOVER_240_0.S[13616]++;header(writer, "Name", "Value");
__CLOVER_240_0.S[13617]++;pair(writer, "id", session.getId());
__CLOVER_240_0.S[13618]++;datePair(writer, "creationTime", session.getCreationTime());
__CLOVER_240_0.S[13619]++;datePair(writer, "lastAccessedTime", session.getLastAccessedTime());
__CLOVER_240_0.S[13620]++;pair(writer, "maxInactiveInterval", session.getMaxInactiveInterval());
__CLOVER_240_0.S[13621]++;pair(writer, "new", session.isNew());
__CLOVER_240_0.S[13622]++;List names = getSorted(session.getAttributeNames());
__CLOVER_240_0.S[13623]++;int count = names.size();
__CLOVER_240_0.S[13624]++;for (int i = 0; (((i < count) && (++__CLOVER_240_0.CT[2287] != 0)) || (++__CLOVER_240_0.CF[2287] == 0)); i++){
{
__CLOVER_240_0.S[13625]++;if ((((i == 0) && (++__CLOVER_240_0.CT[2288] != 0)) || (++__CLOVER_240_0.CF[2288] == 0))){
{
__CLOVER_240_0.S[13626]++;section(writer, "Attributes");
__CLOVER_240_0.S[13627]++;header(writer, "Name", "Value");
}}
__CLOVER_240_0.S[13628]++;String name = (String) names.get(i);
__CLOVER_240_0.S[13629]++;pair(writer, name, session.getAttribute(name));
}}
__CLOVER_240_0.S[13630]++;writer.end(); // Session
}}
__CLOVER_240_0.S[13631]++;object(writer, "Request");
__CLOVER_240_0.S[13632]++;writer.begin("table");
__CLOVER_240_0.S[13633]++;writer.attribute("class", "request-context-object");
// Parameters ...
__CLOVER_240_0.S[13634]++;List parameters = getSorted(_request.getParameterNames());
__CLOVER_240_0.S[13635]++;int count = parameters.size();
__CLOVER_240_0.S[13636]++;for (int i = 0; (((i < count) && (++__CLOVER_240_0.CT[2289] != 0)) || (++__CLOVER_240_0.CF[2289] == 0)); i++){
{
__CLOVER_240_0.S[13637]++;if ((((i == 0) && (++__CLOVER_240_0.CT[2290] != 0)) || (++__CLOVER_240_0.CF[2290] == 0))){
{
__CLOVER_240_0.S[13638]++;section(writer, "Parameters");
__CLOVER_240_0.S[13639]++;header(writer, "Name", "Value(s)");
}}
__CLOVER_240_0.S[13640]++;String name = (String) parameters.get(i);
__CLOVER_240_0.S[13641]++;String[] values = _request.getParameterValues(name);
__CLOVER_240_0.S[13642]++;writer.begin("tr");
__CLOVER_240_0.S[13643]++;writer.attribute("class", getRowClass());
__CLOVER_240_0.S[13644]++;writer.begin("th");
__CLOVER_240_0.S[13645]++;writer.print(name);
__CLOVER_240_0.S[13646]++;writer.end();
__CLOVER_240_0.S[13647]++;writer.begin("td");
__CLOVER_240_0.S[13648]++;if ((((values.length > 1) && (++__CLOVER_240_0.CT[2291] != 0)) || (++__CLOVER_240_0.CF[2291] == 0))){
__CLOVER_240_0.S[13649]++;writer.begin("ul");}
__CLOVER_240_0.S[13650]++;for (int j = 0; (((j < values.length) && (++__CLOVER_240_0.CT[2292] != 0)) || (++__CLOVER_240_0.CF[2292] == 0)); j++){
{
__CLOVER_240_0.S[13651]++;if ((((values.length > 1) && (++__CLOVER_240_0.CT[2293] != 0)) || (++__CLOVER_240_0.CF[2293] == 0))){
__CLOVER_240_0.S[13652]++;writer.beginEmpty("li");}
__CLOVER_240_0.S[13653]++;writer.print(values[j]);
}}
__CLOVER_240_0.S[13654]++;writer.end("tr");
}}
__CLOVER_240_0.S[13655]++;section(writer, "Properties");
__CLOVER_240_0.S[13656]++;header(writer, "Name", "Value");
__CLOVER_240_0.S[13657]++;pair(writer, "authType", _request.getAuthType());
__CLOVER_240_0.S[13658]++;pair(writer, "characterEncoding", _request.getCharacterEncoding());
__CLOVER_240_0.S[13659]++;pair(writer, "contentLength", _request.getContentLength());
__CLOVER_240_0.S[13660]++;pair(writer, "contentType", _request.getContentType());
__CLOVER_240_0.S[13661]++;pair(writer, "method", _request.getMethod());
__CLOVER_240_0.S[13662]++;pair(writer, "pathInfo", _request.getPathInfo());
__CLOVER_240_0.S[13663]++;pair(writer, "pathTranslated", _request.getPathTranslated());
__CLOVER_240_0.S[13664]++;pair(writer, "protocol", _request.getProtocol());
__CLOVER_240_0.S[13665]++;pair(writer, "queryString", _request.getQueryString());
__CLOVER_240_0.S[13666]++;pair(writer, "remoteAddr", _request.getRemoteAddr());
__CLOVER_240_0.S[13667]++;pair(writer, "remoteHost", _request.getRemoteHost());
__CLOVER_240_0.S[13668]++;pair(writer, "remoteUser", _request.getRemoteUser());
__CLOVER_240_0.S[13669]++;String sessionId = _request.getRequestedSessionId();
__CLOVER_240_0.S[13670]++;if ((((sessionId != null) && (++__CLOVER_240_0.CT[2294] != 0)) || (++__CLOVER_240_0.CF[2294] == 0))){
{
__CLOVER_240_0.S[13671]++;StringBuffer buffer = new StringBuffer(sessionId);
__CLOVER_240_0.S[13672]++;if ((((_request.isRequestedSessionIdFromCookie()) && (++__CLOVER_240_0.CT[2295] != 0)) || (++__CLOVER_240_0.CF[2295] == 0))){
__CLOVER_240_0.S[13673]++;buffer.append(" (from cookie)");}
__CLOVER_240_0.S[13674]++;if ((((_request.isRequestedSessionIdFromURL()) && (++__CLOVER_240_0.CT[2296] != 0)) || (++__CLOVER_240_0.CF[2296] == 0))){
__CLOVER_240_0.S[13675]++;buffer.append(" (from URL)");}
__CLOVER_240_0.S[13676]++;if ((((_request.isRequestedSessionIdValid()) && (++__CLOVER_240_0.CT[2297] != 0)) || (++__CLOVER_240_0.CF[2297] == 0))){
__CLOVER_240_0.S[13677]++;buffer.append(" (valid)");}
__CLOVER_240_0.S[13678]++;pair(writer, "requestedSessionId", buffer.toString());
}}
__CLOVER_240_0.S[13679]++;pair(writer, "requestURI", _request.getRequestURI());
__CLOVER_240_0.S[13680]++;pair(writer, "scheme", _request.getScheme());
__CLOVER_240_0.S[13681]++;pair(writer, "serverName", _request.getServerName());
__CLOVER_240_0.S[13682]++;pair(writer, "serverPort", _request.getServerPort());
__CLOVER_240_0.S[13683]++;pair(writer, "contextPath", _request.getContextPath());
__CLOVER_240_0.S[13684]++;pair(writer, "servletPath", _request.getServletPath());
__CLOVER_240_0.S[13685]++;pair(writer, "userPrincipal", _request.getUserPrincipal());
// Now deal with any headers
__CLOVER_240_0.S[13686]++;List headers = getSorted(_request.getHeaderNames());
__CLOVER_240_0.S[13687]++;count = headers.size();
__CLOVER_240_0.S[13688]++;for (int i = 0; (((i < count) && (++__CLOVER_240_0.CT[2298] != 0)) || (++__CLOVER_240_0.CF[2298] == 0)); i++){
{
__CLOVER_240_0.S[13689]++;if ((((i == 0) && (++__CLOVER_240_0.CT[2299] != 0)) || (++__CLOVER_240_0.CF[2299] == 0))){
{
__CLOVER_240_0.S[13690]++;section(writer, "Headers");
__CLOVER_240_0.S[13691]++;header(writer, "Name", "Value");
}}
__CLOVER_240_0.S[13692]++;String name = (String) headers.get(i);
__CLOVER_240_0.S[13693]++;String value = _request.getHeader(name);
__CLOVER_240_0.S[13694]++;pair(writer, name, value);
}}
// Attributes
__CLOVER_240_0.S[13695]++;List attributes = getSorted(_request.getAttributeNames());
__CLOVER_240_0.S[13696]++;count = attributes.size();
__CLOVER_240_0.S[13697]++;for (int i = 0; (((i < count) && (++__CLOVER_240_0.CT[2300] != 0)) || (++__CLOVER_240_0.CF[2300] == 0)); i++){
{
__CLOVER_240_0.S[13698]++;if ((((i == 0) && (++__CLOVER_240_0.CT[2301] != 0)) || (++__CLOVER_240_0.CF[2301] == 0))){
{
__CLOVER_240_0.S[13699]++;section(writer, "Attributes");
__CLOVER_240_0.S[13700]++;header(writer, "Name", "Value");
}}
__CLOVER_240_0.S[13701]++;String name = (String) attributes.get(i);
__CLOVER_240_0.S[13702]++;pair(writer, name, _request.getAttribute(name));
}}
// Cookies ...
__CLOVER_240_0.S[13703]++;Cookie[] cookies = _request.getCookies();
__CLOVER_240_0.S[13704]++;if ((((cookies != null) && (++__CLOVER_240_0.CT[2302] != 0)) || (++__CLOVER_240_0.CF[2302] == 0))){
{
__CLOVER_240_0.S[13705]++;for (int i = 0; (((i < cookies.length) && (++__CLOVER_240_0.CT[2303] != 0)) || (++__CLOVER_240_0.CF[2303] == 0)); i++){
{
__CLOVER_240_0.S[13706]++;if ((((i == 0) && (++__CLOVER_240_0.CT[2304] != 0)) || (++__CLOVER_240_0.CF[2304] == 0))){
{
__CLOVER_240_0.S[13707]++;section(writer, "Cookies");
__CLOVER_240_0.S[13708]++;header(writer, "Name", "Value");
}}
__CLOVER_240_0.S[13709]++;Cookie cookie = cookies[i];
__CLOVER_240_0.S[13710]++;pair(writer, cookie.getName(), cookie.getValue());
}} // Cookies loop
}}
__CLOVER_240_0.S[13711]++;writer.end(); // Request
__CLOVER_240_0.S[13712]++;object(writer, "Servlet");
__CLOVER_240_0.S[13713]++;writer.begin("table");
__CLOVER_240_0.S[13714]++;writer.attribute("class", "request-context-object");
__CLOVER_240_0.S[13715]++;section(writer, "Properties");
__CLOVER_240_0.S[13716]++;header(writer, "Name", "Value");
__CLOVER_240_0.S[13717]++;pair(writer, "servlet", _servlet);
__CLOVER_240_0.S[13718]++;pair(writer, "name", _servlet.getServletName());
__CLOVER_240_0.S[13719]++;pair(writer, "servletInfo", _servlet.getServletInfo());
__CLOVER_240_0.S[13720]++;ServletConfig config = _servlet.getServletConfig();
__CLOVER_240_0.S[13721]++;List names = getSorted(config.getInitParameterNames());
__CLOVER_240_0.S[13722]++;count = names.size();
__CLOVER_240_0.S[13723]++;for (int i = 0; (((i < count) && (++__CLOVER_240_0.CT[2305] != 0)) || (++__CLOVER_240_0.CF[2305] == 0)); i++){
{
__CLOVER_240_0.S[13724]++;if ((((i == 0) && (++__CLOVER_240_0.CT[2306] != 0)) || (++__CLOVER_240_0.CF[2306] == 0))){
{
__CLOVER_240_0.S[13725]++;section(writer, "Init Parameters");
__CLOVER_240_0.S[13726]++;header(writer, "Name", "Value");
}}
__CLOVER_240_0.S[13727]++;String name = (String) names.get(i);
;
__CLOVER_240_0.S[13728]++;pair(writer, name, config.getInitParameter(name));
}}
__CLOVER_240_0.S[13729]++;writer.end(); // Servlet
__CLOVER_240_0.S[13730]++;ServletContext context = config.getServletContext();
__CLOVER_240_0.S[13731]++;object(writer, "Servlet Context");
__CLOVER_240_0.S[13732]++;writer.begin("table");
__CLOVER_240_0.S[13733]++;writer.attribute("class", "request-context-object");
__CLOVER_240_0.S[13734]++;section(writer, "Properties");
__CLOVER_240_0.S[13735]++;header(writer, "Name", "Value");
__CLOVER_240_0.S[13736]++;pair(writer, "majorVersion", context.getMajorVersion());
__CLOVER_240_0.S[13737]++;pair(writer, "minorVersion", context.getMinorVersion());
__CLOVER_240_0.S[13738]++;pair(writer, "serverInfo", context.getServerInfo());
__CLOVER_240_0.S[13739]++;names = getSorted(context.getInitParameterNames());
__CLOVER_240_0.S[13740]++;count = names.size();
__CLOVER_240_0.S[13741]++;for (int i = 0; (((i < count) && (++__CLOVER_240_0.CT[2307] != 0)) || (++__CLOVER_240_0.CF[2307] == 0)); i++){
{
__CLOVER_240_0.S[13742]++;if ((((i == 0) && (++__CLOVER_240_0.CT[2308] != 0)) || (++__CLOVER_240_0.CF[2308] == 0))){
{
__CLOVER_240_0.S[13743]++;section(writer, "Initial Parameters");
__CLOVER_240_0.S[13744]++;header(writer, "Name", "Value");
}}
__CLOVER_240_0.S[13745]++;String name = (String) names.get(i);
__CLOVER_240_0.S[13746]++;pair(writer, name, context.getInitParameter(name));
}}
__CLOVER_240_0.S[13747]++;names = getSorted(context.getAttributeNames());
__CLOVER_240_0.S[13748]++;count = names.size();
__CLOVER_240_0.S[13749]++;for (int i = 0; (((i < count) && (++__CLOVER_240_0.CT[2309] != 0)) || (++__CLOVER_240_0.CF[2309] == 0)); i++){
{
__CLOVER_240_0.S[13750]++;if ((((i == 0) && (++__CLOVER_240_0.CT[2310] != 0)) || (++__CLOVER_240_0.CF[2310] == 0))){
{
__CLOVER_240_0.S[13751]++;section(writer, "Attributes");
__CLOVER_240_0.S[13752]++;header(writer, "Name", "Value");
}}
__CLOVER_240_0.S[13753]++;String name = (String) names.get(i);
__CLOVER_240_0.S[13754]++;pair(writer, name, context.getAttribute(name));
}}
__CLOVER_240_0.S[13755]++;writer.end(); // Servlet Context
__CLOVER_240_0.S[13756]++;writeSystemProperties(writer);
__CLOVER_240_0.S[13757]++;writer.end("table"); // The enclosing border
} finally { }}
private void writeSystemProperties(IMarkupWriter writer)
{try { __CLOVER_240_0.M[3226]++;
__CLOVER_240_0.S[13758]++;Properties properties = null;
__CLOVER_240_0.S[13759]++;object(writer, "JVM System Properties");
__CLOVER_240_0.S[13760]++;try
{
__CLOVER_240_0.S[13761]++;properties = System.getProperties();
}
catch (SecurityException se)
{
__CLOVER_240_0.S[13762]++;writer.print("<p>");
__CLOVER_240_0.S[13763]++;writer.print(se.toString());
__CLOVER_240_0.S[13764]++;return;
}
__CLOVER_240_0.S[13765]++;String pathSeparator = System.getProperty("path.separator", ";");
__CLOVER_240_0.S[13766]++;writer.begin("table");
__CLOVER_240_0.S[13767]++;writer.attribute("class", "request-context-object");
__CLOVER_240_0.S[13768]++;List names = new ArrayList(properties.keySet());
__CLOVER_240_0.S[13769]++;Collections.sort(names);
__CLOVER_240_0.S[13770]++;int count = names.size();
__CLOVER_240_0.S[13771]++;for (int i = 0; (((i < count) && (++__CLOVER_240_0.CT[2311] != 0)) || (++__CLOVER_240_0.CF[2311] == 0)); i++){
{
__CLOVER_240_0.S[13772]++;if ((((i == 0) && (++__CLOVER_240_0.CT[2312] != 0)) || (++__CLOVER_240_0.CF[2312] == 0))){
__CLOVER_240_0.S[13773]++;header(writer, "Name", "Value");}
__CLOVER_240_0.S[13774]++;String name = (String) names.get(i);
__CLOVER_240_0.S[13775]++;String property = properties.getProperty(name);
__CLOVER_240_0.S[13776]++;if ((((property != null && property.indexOf(pathSeparator) > 0 && name.endsWith(".path")) && (++__CLOVER_240_0.CT[2313] != 0)) || (++__CLOVER_240_0.CF[2313] == 0))){
{
__CLOVER_240_0.S[13777]++;writer.begin("tr");
__CLOVER_240_0.S[13778]++;writer.attribute("class", getRowClass());
__CLOVER_240_0.S[13779]++;writer.begin("th");
__CLOVER_240_0.S[13780]++;writer.print(name);
__CLOVER_240_0.S[13781]++;writer.end();
__CLOVER_240_0.S[13782]++;writer.begin("td");
__CLOVER_240_0.S[13783]++;writer.begin("ul");
__CLOVER_240_0.S[13784]++;StringTokenizer tokenizer = new StringTokenizer(property, pathSeparator);
__CLOVER_240_0.S[13785]++;while ((((tokenizer.hasMoreTokens()) && (++__CLOVER_240_0.CT[2314] != 0)) || (++__CLOVER_240_0.CF[2314] == 0))){
{
__CLOVER_240_0.S[13786]++;writer.beginEmpty("li");
__CLOVER_240_0.S[13787]++;writer.print(tokenizer.nextToken());
}}
__CLOVER_240_0.S[13788]++;writer.end("tr");
}}
else{
{
__CLOVER_240_0.S[13789]++;pair(writer, name, property);
}}
}}
__CLOVER_240_0.S[13790]++;writer.end(); // System Properties
} finally { }}
/**
* Invokes {@link #write(IMarkupWriter)}, which is used for debugging.
* Does nothing if the cycle is rewinding.
*
**/
public void render(IMarkupWriter writer, IRequestCycle cycle)
{try { __CLOVER_240_0.M[3227]++;
__CLOVER_240_0.S[13791]++;if ((((!cycle.isRewinding()) && (++__CLOVER_240_0.CT[2315] != 0)) || (++__CLOVER_240_0.CF[2315] == 0))){
__CLOVER_240_0.S[13792]++;write(writer);}
} finally { }}
/**
* Returns the multipart decoder and lazily decodes the request parameters.
* This allows both for this operation to be performed only when really needed
* and for opening the request for reading much later, so that the Engine can
* have a chance to set the encoding that the request needs to use.
*
* @return the multipart decoder or null if not needed for this request
* @since 3.0
**/
private IMultipartDecoder getDecoder()
{try { __CLOVER_240_0.M[3228]++;
__CLOVER_240_0.S[13793]++;if ((((_decoder != null && !_decoded) && (++__CLOVER_240_0.CT[2316] != 0)) || (++__CLOVER_240_0.CF[2316] == 0))){
{
__CLOVER_240_0.S[13794]++;_decoder.decode(_request);
__CLOVER_240_0.S[13795]++;_decoded = true;
}}
__CLOVER_240_0.S[13796]++;return _decoder;
} finally { }}
/**
* Sets the multipart decoder to be used for the request.
*
* @param decoder the multipart decoder
* @since 3.0
**/
public void setDecoder(IMultipartDecoder decoder)
{try { __CLOVER_240_0.M[3229]++;
__CLOVER_240_0.S[13797]++;_decoder = decoder;
__CLOVER_240_0.S[13798]++;_decoded = false;
} finally { }}
/**
* @since 3.1 --- but probably pretty temporary!
*/
public IApplicationSpecification getApplicationSpecification()
{try { __CLOVER_240_0.M[3230]++;
__CLOVER_240_0.S[13799]++;return _specification;
} finally { }}
}