public static String getStackTrace(Throwable t) { String stackTrace = null; try { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); pw.close(); sw.close(); stackTrace = sw.getBuffer().toString(); } catch (Exception ex) { } return stackTrace; }
DomElement createDomElement(WApplication app) { DomElement result = null; if (this.isInLayout()) { this.setJavaScriptMember(WT_RESIZE_JS, "function() {}"); } if (app.getEnvironment().agentIsIElt(9) || app.getEnvironment().getAgent() == WEnvironment.UserAgent.MobileWebKitAndroid) { result = DomElement.createNew(DomElementType.DomElement_DIV); if (this.alternative_ != null) { result.addChild(this.alternative_.createSDomElement(app)); } } else { DomElement media = this.createMediaDomElement(); DomElement wrap = null; if (this.isInLayout()) { media.setProperty(Property.PropertyStylePosition, "absolute"); media.setProperty(Property.PropertyStyleLeft, "0"); media.setProperty(Property.PropertyStyleRight, "0"); wrap = DomElement.createNew(DomElementType.DomElement_DIV); wrap.setProperty(Property.PropertyStylePosition, "relative"); } result = wrap != null ? wrap : media; if (wrap != null) { this.mediaId_ = this.getId() + "_media"; media.setId(this.mediaId_); } else { this.mediaId_ = this.getId(); } this.updateMediaDom(media, true); for (int i = 0; i < this.sources_.size(); ++i) { DomElement src = DomElement.createNew(DomElementType.DomElement_SOURCE); src.setId(this.mediaId_ + "s" + String.valueOf(i)); this.renderSource(src, this.sources_.get(i), i + 1 >= this.sources_.size()); media.addChild(src); } this.sourcesRendered_ = this.sources_.size(); this.sourcesChanged_ = false; if (wrap != null) { wrap.addChild(media); } } if (this.isInLayout()) { StringWriter ss = new StringWriter(); ss.append("function(self, w, h) {"); if (this.mediaId_.length() != 0) { ss.append( "v=" + this.getJsMediaRef() + ";if(v){v.setAttribute('width', w);v.setAttribute('height', h);}"); } if (this.alternative_ != null) { ss.append("a=" + this.alternative_.getJsRef() + ";if(a && a.") .append(WT_RESIZE_JS) .append(")a.") .append(WT_RESIZE_JS) .append("(a, w, h);"); } ss.append("}"); this.setJavaScriptMember(WT_RESIZE_JS, ss.toString()); } this.setId(result, app); this.updateDom(result, true); if (this.isInLayout()) { result.setEvent(PLAYBACKSTARTED_SIGNAL, ""); result.setEvent(PLAYBACKPAUSED_SIGNAL, ""); result.setEvent(ENDED_SIGNAL, ""); result.setEvent(TIMEUPDATED_SIGNAL, ""); result.setEvent(VOLUMECHANGED_SIGNAL, ""); } this.setJavaScriptMember("mediaId", "'" + this.mediaId_ + "'"); return result; }
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (filterConfig == null) return; StringWriter sw = new StringWriter(); PrintWriter writer = new PrintWriter(sw); writer.println( (new StringBuilder("Request Received at ")) .append(new Timestamp(System.currentTimeMillis())) .toString()); writer.println( (new StringBuilder(" characterEncoding=")) .append(request.getCharacterEncoding()) .toString()); writer.println( (new StringBuilder(" contentLength=")).append(request.getContentLength()).toString()); writer.println( (new StringBuilder(" contentType=")).append(request.getContentType()).toString()); writer.println( (new StringBuilder(" locale=")).append(request.getLocale()).toString()); writer.print(" locales="); Enumeration locales = request.getLocales(); boolean first = true; Locale locale; for (; locales.hasMoreElements(); writer.print(locale.toString())) { locale = (Locale) locales.nextElement(); if (first) first = false; else writer.print(", "); } writer.println(); for (Enumeration names = request.getParameterNames(); names.hasMoreElements(); writer.println()) { String name = (String) names.nextElement(); writer.print((new StringBuilder(" parameter=")).append(name).append("=").toString()); String values[] = request.getParameterValues(name); for (int i = 0; i < values.length; i++) { if (i > 0) writer.print(", "); writer.print(values[i]); } } writer.println( (new StringBuilder(" protocol=")).append(request.getProtocol()).toString()); writer.println( (new StringBuilder(" remoteAddr=")).append(request.getRemoteAddr()).toString()); writer.println( (new StringBuilder(" remoteHost=")).append(request.getRemoteHost()).toString()); writer.println( (new StringBuilder(" scheme=")).append(request.getScheme()).toString()); writer.println( (new StringBuilder(" serverName=")).append(request.getServerName()).toString()); writer.println( (new StringBuilder(" serverPort=")).append(request.getServerPort()).toString()); writer.println( (new StringBuilder(" isSecure=")).append(request.isSecure()).toString()); if (request instanceof HttpServletRequest) { writer.println("---------------------------------------------"); HttpServletRequest hrequest = (HttpServletRequest) request; writer.println( (new StringBuilder(" contextPath=")).append(hrequest.getContextPath()).toString()); Cookie cookies[] = hrequest.getCookies(); if (cookies == null) cookies = new Cookie[0]; for (int i = 0; i < cookies.length; i++) writer.println( (new StringBuilder(" cookie=")) .append(cookies[i].getName()) .append("=") .append(cookies[i].getValue()) .toString()); String name; String value; for (Enumeration names = hrequest.getHeaderNames(); names.hasMoreElements(); writer.println( (new StringBuilder(" header=")) .append(name) .append("=") .append(value) .toString())) { name = (String) names.nextElement(); value = hrequest.getHeader(name); } writer.println( (new StringBuilder(" method=")).append(hrequest.getMethod()).toString()); writer.println( (new StringBuilder(" pathInfo=")).append(hrequest.getPathInfo()).toString()); writer.println( (new StringBuilder(" queryString=")).append(hrequest.getQueryString()).toString()); writer.println( (new StringBuilder(" remoteUser="******"requestedSessionId=")) .append(hrequest.getRequestedSessionId()) .toString()); writer.println( (new StringBuilder(" requestURI=")).append(hrequest.getRequestURI()).toString()); writer.println( (new StringBuilder(" servletPath=")).append(hrequest.getServletPath()).toString()); } writer.println("============================================="); writer.flush(); filterConfig.getServletContext().log(sw.getBuffer().toString()); chain.doFilter(request, response); }