public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { res.setHeader("A", "a"); res.setHeader("Content-Length", "0"); res.setHeader("B", "b"); }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-cache"); response.setContentType("text/xml;charset=gbk"); String cmd = JUtil.convertNull(request.getParameter("cmd")); String xml = null; try { if (cmd.equals("calExterContractApplyType")) { // 根据公司ID,获得对外合同申请的合同类别 xml = this.calExterContractApplyType(request, response); } else if (cmd.equals("calDefaultExterContractApprover")) { // 获得对外合同申请的默认审批人 xml = this.calDefaultExterContractApprover(request, response); } else if (cmd.equals("calDefaultGnOrgApprover")) { // 获得国内合作渠道申请的默认审批人 xml = this.calDefaultGnOrgApprover(request, response); } else if (cmd.equals("calNeedInputMoney")) { xml = this.calNeedInputMoney(request, response); } else if (cmd.equals("checkRepeatGnOrg")) { // 检查国内合作渠道的名称是否有重复 xml = this.checkRepeatGnOrg(request, response); } else { xml = ""; } } catch (Throwable e) { e.printStackTrace(); } java.io.PrintWriter out = response.getWriter(); out.write(xml); }
// Set an appropriate CORS header if requested and if allowed private void setCorsHeader(HttpServletRequest pReq, HttpServletResponse pResp) { String origin = requestHandler.extractCorsOrigin(pReq.getHeader("Origin")); if (origin != null) { pResp.setHeader("Access-Control-Allow-Origin", origin); pResp.setHeader("Access-Control-Allow-Credentials", "true"); } }
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException { try { ConnectionPool conPool = getConnectionPool(); if (!realAuthentication(request, conPool)) { String queryString = request.getQueryString(); if (request.getQueryString() == null) { queryString = ""; } // if user is not authenticated send to signin response.sendRedirect( response.encodeRedirectURL(URLAUTHSIGNIN + "?" + URLBUY + "?" + queryString)); } else { response.setHeader("Cache-Control", "no-cache"); response.setHeader("Expires", "0"); response.setHeader("Pragma", "no-cache"); response.setContentType("text/html"); String errorMessage = processRequest(request, response, conPool); if (errorMessage != null) { request.setAttribute(StringInterface.ERRORPAGEATTR, errorMessage); RequestDispatcher rd = getServletContext().getRequestDispatcher(PATHUSERERROR); rd.include(request, response); } } } catch (Exception e) { throw new ServletException(e); } }
private void init(HttpServletResponse response) { response.setHeader("Pragma", "no-cache"); // HTTP 1.0 response.setHeader("Cache-Control", "no-cache"); // HTTP 1.1 response.setDateHeader("Expires", 0); // prevents caching at the proxy server response.setHeader("Cache-Control", "private"); // HTTP 1.1 response.setHeader("Cache-Control", "no-store"); // HTTP 1.1 response.setHeader("Cache-Control", "max-stale=0"); // HTTP 1.1 response.setContentType("text/html"); }
/** * This method will open the sample report pdf. * * @param reportFilePath - full path of the sample report to be shown. * @param request - instance of HttpServletRequest * @param response - instance of HttpServletResponse * @throws ServletException - error * @throws IOException - error */ private static void showSampleReport( String reportFilePath, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (null != request.getSession().getAttribute(ReportServiceConstant.VIEW_SAMPLE_REPORT) && request .getSession() .getAttribute(ReportServiceConstant.VIEW_SAMPLE_REPORT) .toString() .equalsIgnoreCase("Y")) { ServletOutputStream output = null; try { FileInputStream fis = new FileInputStream(reportFilePath); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buf = new byte[256]; try { for (int readNum; (readNum = fis.read(buf)) != -1; ) { baos.write(buf, 0, readNum); // no doubt here is 0 // Writes len bytes from the specified byte array starting at offset off to this byte // array output stream. } } catch (IOException ex) { ex.printStackTrace(); } if (null != baos) { // Init servlet response. response.reset(); response.setContentType("application/pdf"); response.setContentLength(baos.size()); response.setHeader("Content-disposition", "inline; filename=\"" + reportFilePath); response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); // response.setHeader("Transfer-Encoding", "identity"); output = response.getOutputStream(); output.write(baos.toByteArray(), 0, baos.size()); // Finalize task. output.flush(); } } catch (Exception exception) { OPPE_LOG.error("ERROR.SHOW_PDF.ERROR", exception); } finally { // Gently close streams. close((Closeable) output); } } }
private void outputJson(HttpServletResponse response, Response<String> kv) throws IOException, JsonGenerationException, JsonMappingException { response.setContentType("application/json;charset=UTF-8"); response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); response.setContentType("application/json"); PrintWriter out = response.getWriter(); ObjectMapper om = JsonHelper.getObjectMapperInstance(); out.print(om.writeValueAsString(kv)); out.flush(); out.close(); }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String script = request.getParameter("bsh.script"); String client = request.getParameter("bsh.client"); String output = request.getParameter("bsh.servlet.output"); String captureOutErr = request.getParameter("bsh.servlet.captureOutErr"); boolean capture = false; if (captureOutErr != null && captureOutErr.equalsIgnoreCase("true")) capture = true; Object scriptResult = null; Exception scriptError = null; StringBuffer scriptOutput = new StringBuffer(); if (script != null) { try { scriptResult = evalScript(script, scriptOutput, capture, request, response); } catch (Exception e) { scriptError = e; } } response.setHeader("Bsh-Return", String.valueOf(scriptResult)); if ((output != null && output.equalsIgnoreCase("raw")) || (client != null && client.equals("Remote"))) sendRaw(request, response, scriptError, scriptResult, scriptOutput); else sendHTML(request, response, script, scriptError, scriptResult, scriptOutput, capture); }
/** * Sets a status and sends an info message. * * @param code status code * @param message info message * @throws IOException I/O exception */ public void status(final int code, final String message) throws IOException { log(true, code, message); if (session != null) session.close(); res.resetBuffer(); res.setStatus(code); if (code == SC_UNAUTHORIZED) res.setHeader(WWW_AUTHENTICATE, BASIC); if (message != null) res.getOutputStream().write(token(message)); }
private void sendAuthnResponse( HttpServletRequest request, HttpServletResponse response, String authnResponse) { if (debug.messageEnabled()) { debug.message("CDCClientServlet.sendAuthnResponse: Called"); } try { if (debug.messageEnabled()) { debug.message("CDCClientServlet.sendAuthnResponse: " + "AuthnResponse= " + authnResponse); } response.setContentType("text/html"); response.setHeader("Pragma", "no-cache"); response.setHeader(RESPONSE_HEADER_ALERT, RESPONSE_HEADER_ALERT_VALUE); if (authnResponse.contains(FORBIDDEN_STR_MATCH)) { if (debug.messageEnabled()) { debug.message( "CDCClientServlet.sendAuthnResponse: " + "AuthnResponse showing 403 error page"); } response.sendError(HttpServletResponse.SC_FORBIDDEN); return; } if (authnResponse.contains(SERVER_ERROR_STR_MATCH)) { if (debug.messageEnabled()) { debug.error( "CDCClientServlet.sendAuthnResponse: " + "ERROR: An application error has occured."); } response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } PrintWriter out = response.getWriter(); out.println(authnResponse); out.close(); if (debug.messageEnabled()) { debug.message("CDCClientServlet.sendAuthnResponse: " + "AuthnResponse sent successfully"); } return; } catch (IOException ioe) { debug.error("CDCClientServlet.sendAuthnResponse:" + ioe.getMessage()); } }
/** * OPTION requests are treated as CORS preflight requests * * @param req the original request * @param resp the response the answer are written to */ @Override protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Map<String, String> responseHeaders = requestHandler.handleCorsPreflightRequest( req.getHeader("Origin"), req.getHeader("Access-Control-Request-Headers")); for (Map.Entry<String, String> entry : responseHeaders.entrySet()) { resp.setHeader(entry.getKey(), entry.getValue()); } }
private void setNoCacheHeaders(HttpServletResponse pResp) { pResp.setHeader("Cache-Control", "no-cache"); pResp.setHeader("Pragma", "no-cache"); // Check for a date header and set it accordingly to the recommendations of // RFC-2616 (http://tools.ietf.org/html/rfc2616#section-14.21) // // "To mark a response as "already expired," an origin server sends an // Expires date that is equal to the Date header value. (See the rules // for expiration calculations in section 13.2.4.)" // // See also #71 long now = System.currentTimeMillis(); pResp.setDateHeader("Date", now); // 1h in the past since it seems, that some servlet set the date header on their // own so that it cannot be guaranteed that these headers are really equals. // It happened on Tomcat that Date: was finally set *before* Expires: in the final // answers some times which seems to be an implementation peculiarity from Tomcat pResp.setDateHeader("Expires", now - 3600000); }
public static void setBrowserInfiniteCookie( HttpServletResponse response, String value, int nServerPort) { String params = null; if ((443 == nServerPort) || (8443 == nServerPort)) { params = "; path=/; HttpOnly; Secure"; } else { params = "; path=/; HttpOnly"; } response.setHeader("SET-COOKIE", "infinitecookie=" + value + params); // (all this is needed in order to support HTTP only cookies) } // TESTED
/** * this is the main method of the servlet that will service all get requests. * * @param request HttpServletRequest * @param responce HttpServletResponce */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = null; try { try { session = request.getSession(true); } catch (Exception e) { Log.error(e, "PingSession2.doGet(...): error getting session"); // rethrow the exception for handling in one place. throw e; } // Get the session data value Integer ival = (Integer) session.getAttribute("sessiontest.counter"); // if there is not a counter then create one. if (ival == null) { ival = new Integer(1); } else { ival = new Integer(ival.intValue() + 1); } session.setAttribute("sessiontest.counter", ival); // if the session count is equal to five invalidate the session if (ival.intValue() == 5) { session.invalidate(); } try { // Output the page response.setContentType("text/html"); response.setHeader("SessionTrackingTest-counter", ival.toString()); PrintWriter out = response.getWriter(); out.println( "<html><head><title>Session Tracking Test 2</title></head><body><HR><BR><FONT size=\"+2\" color=\"#000066\">HTTP Session Test 2: Session create/invalidate <BR></FONT><FONT size=\"+1\" color=\"#000066\">Init time: " + initTime + "</FONT><BR><BR>"); hitCount++; out.println( "<B>Hit Count: " + hitCount + "<BR>Session hits: " + ival + "</B></body></html>"); } catch (Exception e) { Log.error(e, "PingSession2.doGet(...): error getting session information"); // rethrow the exception for handling in one place. throw e; } } catch (Exception e) { // log the excecption Log.error(e, "PingSession2.doGet(...): error."); // set the server responce to 500 and forward to the web app defined error page response.sendError(500, "PingSession2.doGet(...): error. " + e.toString()); } } // end of the method
private void setResponseHeader( HttpServletResponse response, String uri, String transferEncoding) { // LogUtil.logDebug( uri + ".Accept-Encoding: "+ transferEncoding); String ext = null; int dot = uri.lastIndexOf("."); if (dot != -1) { ext = uri.substring(dot + 1); } if (ext != null && ext.length() > 0) { Integer expires = (Integer) expiresMap.get(ext); if (expires != null) { // LogUtil.logDebug( uri + ".Expires: "+ expires.intValue()); if (expires.intValue() > 0) { response.setHeader("Cache-Control", "max-age=" + expires.intValue()); // HTTP 1.1 } else { response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-cache"); // HTTP 1.0 response.setDateHeader("Expires", expires.intValue()); } } } }
/** @service the servlet service request. called once for each servlet request. */ public void service(HttpServletRequest servReq, HttpServletResponse servRes) throws IOException { String name; String value[]; String val; servRes.setHeader("AUTHORIZATION", "user fred:mypassword"); ServletOutputStream out = servRes.getOutputStream(); HttpSession session = servReq.getSession(true); session.setAttribute("timemilis", new Long(System.currentTimeMillis())); if (session.isNew()) { out.println("<p> Session is new "); } else { out.println("<p> Session is not new "); } Long l = (Long) session.getAttribute("timemilis"); out.println("<p> Session id = " + session.getId()); out.println("<p> TimeMillis = " + l); out.println("<H2>Servlet Params</H2>"); Enumeration e = servReq.getParameterNames(); while (e.hasMoreElements()) { name = (String) e.nextElement(); value = servReq.getParameterValues(name); out.println(name + " : "); for (int i = 0; i < value.length; ++i) { out.println(value[i]); } out.println("<p>"); } out.println("<H2> Request Headers : </H2>"); e = servReq.getHeaderNames(); while (e.hasMoreElements()) { name = (String) e.nextElement(); val = (String) servReq.getHeader(name); out.println("<p>" + name + " : " + val); } try { BufferedReader br = servReq.getReader(); String line = null; while (null != (line = br.readLine())) { out.println(line); } } catch (IOException ie) { ie.printStackTrace(); } session.invalidate(); }
/** * Sets a status and sends an info message. * * @param code status code * @param message info message * @param error treat as error (use web server standard output) * @throws IOException I/O exception */ public void status(final int code, final String message, final boolean error) throws IOException { try { log(message, code); res.resetBuffer(); if (code == SC_UNAUTHORIZED) res.setHeader(WWW_AUTHENTICATE, BASIC); if (error && code >= SC_BAD_REQUEST) { res.sendError(code, message); } else { res.setStatus(code); if (message != null) res.getOutputStream().write(token(message)); } } catch (final IllegalStateException ex) { log(Util.message(ex), SC_INTERNAL_SERVER_ERROR); } }
private void sendAuthnResponse( HttpServletRequest request, HttpServletResponse response, String authnResponse) { if (debug.messageEnabled()) { debug.message("CDCClientServlet.sendAuthnResponse: Called"); } try { if (debug.messageEnabled()) { debug.message("CDCClientServlet.sendAuthnResponse: " + "AuthnResponse= " + authnResponse); } response.setContentType("text/html"); response.setHeader("Pragma", "no-cache"); PrintWriter out = response.getWriter(); out.println(authnResponse); out.close(); if (debug.messageEnabled()) { debug.message("CDCClientServlet.sendAuthnResponse: " + "AuthnResponse sent successfully"); } return; } catch (IOException ioe) { debug.error("CDCServlet.sendAuthnResponse:" + ioe.getMessage()); } }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/html"); response.setHeader("X-Powered-By", "JSP/2.2"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; _jspx_resourceInjector = (org.glassfish.jsp.api.ResourceInjector) application.getAttribute("com.sun.appserv.jsp.resource.injector"); response.sendRedirect(request.getContextPath() + "/main"); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); else throw new ServletException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html;charset=EUC-KR"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\r\n"); out.write("<HTML>\r\n"); out.write("<BODY bgcolor=\"white\">\r\n"); out.write("<H3>요청 정보 </H3>\r\n"); response.setDateHeader("Expires", 0); response.setHeader("Pragma", "no-cache"); if (request.getProtocol().equals("HTTP/1.1")) { response.setHeader("Cache-Control", "no-cache"); } out.write("\r\n"); out.write("<FONT size=\"4\">\r\n"); out.write("JSP Request Method:"); out.print(request.getMethod()); out.write("<BR>\r\n"); out.write("Request URI:"); out.print(request.getRequestURI()); out.write("<BR>\r\n"); out.write("Request Protocol:"); out.print(request.getProtocol()); out.write("<BR>\r\n"); out.write("Servlet path:"); out.print(request.getServletPath()); out.write("<BR>\r\n"); out.write("Query string:"); out.print(request.getQueryString()); out.write("<BR>\r\n"); out.write("Content length:"); out.print(request.getContentLength()); out.write("<BR>\r\n"); out.write("Content type:"); out.print(request.getContentType()); out.write("<BR>\r\n"); out.write("Server name:"); out.print(request.getServerName()); out.write("<BR>\r\n"); out.write("Server port:"); out.print(request.getServerPort()); out.write("<BR>\r\n"); out.write("Remote address:"); out.print(request.getRemoteAddr()); out.write("<BR>\r\n"); out.write("Remote host:"); out.print(request.getRemoteHost()); out.write("<BR>\r\n"); out.write("<HR>\r\n"); out.write("The browser you are using is "); out.print(request.getHeader("User-Agent")); out.write("\r\n"); out.write("</FONT>\r\n"); out.write("</BODY>\r\n"); out.write("</HTML>\r\n"); out.write("\t"); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); } }
public void doGet(HttpServletRequest request, HttpServletResponse response) { response.setContentType("text/html"); PrintWriter webPageOutput = null; try { webPageOutput = response.getWriter(); } catch (IOException error) { Routines.writeToLog(servletName, "getWriter error : " + error, false, context); } HttpSession session = request.getSession(); session.setAttribute("redirect", request.getRequestURL() + "?" + request.getQueryString()); Connection database = null; try { database = pool.getConnection(servletName); } catch (SQLException error) { Routines.writeToLog(servletName, "Unable to connect to database : " + error, false, context); } if (Routines.loginCheck(true, request, response, database, context)) { return; } String server = context.getInitParameter("server"); boolean liveSever = false; if (server == null) { server = ""; } if (server.equals("live")) { response.setHeader("Refresh", "60"); } Routines.WriteHTMLHead( "View System Log", // title false, // showMenu 13, // menuHighLight false, // seasonsMenu false, // weeksMenu false, // scores false, // standings false, // gameCenter false, // schedules false, // previews false, // teamCenter false, // draft database, // database request, // request response, // response webPageOutput, // webPageOutput context); // context webPageOutput.println("<CENTER>"); webPageOutput.println( "<IMG SRC=\"../Images/Admin.gif\"" + " WIDTH='125' HEIGHT='115' ALT='Admin'>"); webPageOutput.println("</CENTER>"); pool.returnConnection(database); webPageOutput.println(Routines.spaceLines(1)); Routines.tableStart(false, webPageOutput); Routines.tableHeader("System Log", 0, webPageOutput); Routines.tableDataStart(true, false, false, true, true, 0, 0, "scoresrow", webPageOutput); boolean firstLine = true; int numOfLines = 0; try { String file = context.getRealPath("/"); FileReader logFile = new FileReader(file + "/Data/log.txt"); BufferedReader logFileBuffer = new BufferedReader(logFile); boolean endOfFile = false; while (!endOfFile) { String logFileText = logFileBuffer.readLine(); if (logFileText == null) { endOfFile = true; } else { if (firstLine) { firstLine = false; } else { webPageOutput.println(Routines.spaceLines(1)); } numOfLines++; webPageOutput.println(logFileText); } } logFileBuffer.close(); } catch (IOException error) { Routines.writeToLog(servletName, "Problem with log file : " + error, false, context); } Routines.tableDataEnd(false, true, true, webPageOutput); Routines.tableEnd(webPageOutput); if (numOfLines < 20) { webPageOutput.println(Routines.spaceLines(20 - numOfLines)); } Routines.WriteHTMLTail(request, response, webPageOutput); }
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { Locales.setCurrent(request); if (Users.getCurrent() == null) { // for a bug in websphere portal 5.1 with Domino LDAP Users.setCurrent((String) request.getSession().getAttribute("xava.user")); } request.getParameter("application"); // for a bug in websphere 5.1 request.getParameter("module"); // for a bug in websphere 5.1 Tab tab = (Tab) request.getSession().getAttribute("xava_reportTab"); int[] selectedRowsNumber = (int[]) request.getSession().getAttribute("xava_selectedRowsReportTab"); Map[] selectedKeys = (Map[]) request.getSession().getAttribute("xava_selectedKeysReportTab"); int[] selectedRows = getSelectedRows(selectedRowsNumber, selectedKeys, tab); request.getSession().removeAttribute("xava_selectedRowsReportTab"); Integer columnCountLimit = (Integer) request.getSession().getAttribute("xava_columnCountLimitReportTab"); request.getSession().removeAttribute("xava_columnCountLimitReportTab"); setDefaultSchema(request); String user = (String) request.getSession().getAttribute("xava_user"); request.getSession().removeAttribute("xava_user"); Users.setCurrent(user); String uri = request.getRequestURI(); if (uri.endsWith(".pdf")) { InputStream is; JRDataSource ds; Map parameters = new HashMap(); synchronized (tab) { tab.setRequest(request); parameters.put("Title", tab.getTitle()); parameters.put("Organization", getOrganization()); parameters.put("Date", getCurrentDate()); for (String totalProperty : tab.getTotalPropertiesNames()) { parameters.put(totalProperty + "__TOTAL__", getTotal(request, tab, totalProperty)); } TableModel tableModel = getTableModel(request, tab, selectedRows, false, true, null); tableModel.getValueAt(0, 0); if (tableModel.getRowCount() == 0) { generateNoRowsPage(response); return; } is = getReport(request, response, tab, tableModel, columnCountLimit); ds = new JRTableModelDataSource(tableModel); } JasperPrint jprint = JasperFillManager.fillReport(is, parameters, ds); response.setContentType("application/pdf"); response.setHeader( "Content-Disposition", "inline; filename=\"" + getFileName(tab) + ".pdf\""); JasperExportManager.exportReportToPdfStream(jprint, response.getOutputStream()); } else if (uri.endsWith(".csv")) { String csvEncoding = XavaPreferences.getInstance().getCSVEncoding(); if (!Is.emptyString(csvEncoding)) { response.setCharacterEncoding(csvEncoding); } response.setContentType("text/x-csv"); response.setHeader( "Content-Disposition", "inline; filename=\"" + getFileName(tab) + ".csv\""); synchronized (tab) { tab.setRequest(request); response .getWriter() .print( TableModels.toCSV( getTableModel(request, tab, selectedRows, true, false, columnCountLimit))); } } else { throw new ServletException( XavaResources.getString("report_type_not_supported", "", ".pdf .csv")); } } catch (Exception ex) { log.error(ex.getMessage(), ex); throw new ServletException(XavaResources.getString("report_error")); } finally { request.getSession().removeAttribute("xava_reportTab"); } }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/html"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("<!--%@ page errorPage=\"/error.jsp\" %-->\n"); response.setHeader("Pragma", "no-cache"); // HTTP 1.0 response.setDateHeader("Expires", 0); response.setHeader("Cache-Control", "no-cache"); // HTTP 1.1 String _adminid = ""; String _adminname = ""; String _admintype = ""; String _admingroup = ""; String _approval = ""; String _adminclass = ""; String _adminmail = ""; try { _adminid = (String) session.getAttribute("adminid"); if (_adminid == null || _adminid.length() == 0 || _adminid.equals("null")) { response.sendRedirect("/admin/login_first.html"); return; } _adminname = (String) session.getAttribute("adminname"); _admintype = (String) session.getAttribute("admintype"); _admingroup = (String) session.getAttribute("admingroup"); _approval = (String) session.getAttribute("approval"); _adminclass = (String) session.getAttribute("adminclass"); _adminmail = (String) session.getAttribute("admin_email"); // session.setMaxInactiveInterval(60*60); } catch (Exception e) { response.sendRedirect("/admin/login_first.html"); return; } out.write('\n'); out.write('\n'); out.write('\n'); String password = request.getParameter("password"); String fromURL = request.getParameter("fromURL"); String oldPassword = ""; String sql = ""; int iCnt = 0; boolean isSucceeded = false; String strMsg = ""; Connection conn = null; MatrixDataSet matrix = null; DataProcess dataProcess = null; PreparedStatement pstmt = null; String targetUrl = ""; try { if (password.equals("1111")) { throw new UserDefinedException( "The new password is not acceptable. Change your password."); } Context ic = new InitialContext(); DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/scm"); conn = ds.getConnection(); matrix = new dbconn.MatrixDataSet(); dataProcess = new DataProcess(); sql = " select password " + " from admin_01t " + " where adminid = '" + _adminid + "' "; iCnt = dataProcess.RetrieveData(sql, matrix, conn); if (iCnt > 0) { oldPassword = matrix.getRowData(0).getData(0); } else { throw new UserDefinedException("Can't find User Information."); } if (password.equals(oldPassword)) { throw new UserDefinedException( "The new password is not acceptable. Change your password."); } // update ó¸®... int idx = 0; conn.setAutoCommit(false); sql = " update admin_01t " + " set password = ?, pw_date = sysdate() " + " where adminid = ? "; pstmt = conn.prepareStatement(sql); pstmt.setString(++idx, password); pstmt.setString(++idx, _adminid); iCnt = pstmt.executeUpdate(); if (iCnt != 1) { throw new UserDefinedException("Password update failed."); } conn.commit(); isSucceeded = true; } catch (UserDefinedException ue) { try { conn.rollback(); } catch (Exception ex) { } strMsg = ue.getMessage(); } catch (Exception e) { try { conn.rollback(); } catch (Exception ex) { } System.out.println("Exception /admin/resetAdminPasswd : " + e.getMessage()); throw e; } finally { if (pstmt != null) { try { pstmt.close(); } catch (Exception e) { } } if (conn != null) { try { conn.setAutoCommit(true); } catch (Exception e) { } conn.close(); } } // °á°ú ¸Þ½ÃÁö ó¸® if (isSucceeded) { // where to go? if (fromURL.equals("menu")) { targetUrl = ""; } else { targetUrl = "/admin/index2.jsp"; } strMsg = "The data are successfully processed."; } else { strMsg = "The operation failed.\\n" + strMsg; targetUrl = "/admin/resetAdminPasswdForm.jsp"; } out.write("\n"); out.write("<html>\n"); out.write("<head>\n"); out.write("<title></title>\n"); out.write("<link href=\"/common/css/style.css\" rel=\"stylesheet\" type=\"text/css\">\n"); out.write("</head>\n"); out.write("<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>\n"); out.write("<form name=\"form1\" method=\"post\" action=\""); out.print(targetUrl); out.write("\">\n"); out.write("<input type='hidden' name='fromURL' value='"); out.print(fromURL); out.write("'>\n"); out.write("</form>\n"); out.write("<script language=\"javascript\">\n"); if (targetUrl.length() > 0) { out.write("\n"); out.write(" alert('"); out.print(strMsg); out.write("');\n"); out.write(" document.form1.submit();\n"); } out.write("\n"); out.write("</script>\n"); out.write("<table width='840' border='0' cellspacing='0' cellpadding='0'><tr><td>\n"); out.write("\n"); out.write("<table width='99%' border='0' cellspacing='0' cellpadding='0'>\n"); out.write("<tr>\n"); out.write(" <td height='15' colspan='2'></td>\n"); out.write("</tr>\n"); out.write("<tr>\n"); out.write(" <td width='3%'><img src='/img/title_icon.gif'></td>\n"); out.write(" <td width='*' class='left_title'>Password Change</td>\n"); out.write("</tr>\n"); out.write("<tr>\n"); out.write(" <td width='100%' height='2' colspan='2'><hr width='100%'></td>\n"); out.write("</tr>\n"); out.write("<tr>\n"); out.write(" <td height='10' colspan='2'></td>\n"); out.write("</tr>\n"); out.write("</table>\n"); out.write("\n"); out.write("<table width='90%' border='0' cellspacing='0' cellpadding='0' align='center'>\n"); out.write("<tr>\n"); out.write(" <td width='100%' align='center'><img border=\"0\" src=\"/img/pass.jpg\">\n"); out.write(" <br><br>\n"); out.write(" <b>The Password has been changed successfully.</b></td>\n"); out.write("</tr>\n"); out.write("</table>\n"); out.println(CopyRightLogo()); out.write("\n"); out.write("</tr></td></table>\n"); out.write("</body>\n"); out.write("</html>"); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) { } if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }
/** * This method handles response of showing pdf servlet. * * @param request - instance of HttpServletRequest * @param response - instance of HttpServletResponse * @throws ServletException - error * @throws IOException - error */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String preview = request.getParameter(PREVIEW_REPORT_PARAMETER); String sampleReportParam = request.getParameter(SAMPLE_REPORT_PARAM); if (null != sampleReportParam) { String sampleReportPath = ""; if (sampleReportParam.equalsIgnoreCase(ReportServiceConstant.PROVIDER_SUMMARY)) { sampleReportPath = WL_HOME_PATH + RESOURCES_PATH + ReportServiceConstant.PROVIDER_SUMMARY_SAMPLE_FILE; showSampleReport(sampleReportPath, request, response); } else if (sampleReportParam.equalsIgnoreCase(ReportServiceConstant.COMPARATIVE_SUMMARY)) { sampleReportPath = WL_HOME_PATH + RESOURCES_PATH + ReportServiceConstant.COMPARITIVE_SUMMARY_SAMPLE_FILE; showSampleReport(sampleReportPath, request, response); } else if (sampleReportParam.equalsIgnoreCase(ReportServiceConstant.EXECUTIVE_SUMMARY)) { sampleReportPath = WL_HOME_PATH + RESOURCES_PATH + ReportServiceConstant.EXECUTIVE_SUMMARY_SAMPLE_FILE; showSampleReport(sampleReportPath, request, response); } } else if (null != preview && STR_TRUE.equals(preview)) { // report generation using OracleBI ServletOutputStream output = null; byte[] rawBinaryFile = null; Map<String, String> parameterMap = null; PublicReportServicePortClient client = null; FileStream fileStream = null; try { if (null != request.getSession().getAttribute(REPORTS_PARAMETERS_MAP)) { parameterMap = (Map<String, String>) request.getSession().getAttribute(REPORTS_PARAMETERS_MAP); // request.getSession().removeAttribute(REPORTS_PARAMETERS_MAP); } if (null != parameterMap && parameterMap.containsKey("REPORT_PATH")) { client = new PublicReportServicePortClient(); fileStream = client.generateReport(parameterMap); rawBinaryFile = fileStream.getFileContent(); } if (null != rawBinaryFile) { // Init servlet response. response.reset(); response.setContentType("application/pdf"); response.setContentLength(rawBinaryFile.length); response.setHeader( "Content-disposition", "inline; filename=\"" + fileStream.getFileName() + ".pdf\""); response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); // response.setHeader("Transfer-Encoding", "identity"); output = response.getOutputStream(); output.write(rawBinaryFile, 0, rawBinaryFile.length); // Finalize task. output.flush(); } } catch (Exception exception) { OPPE_LOG.error("ERROR.SHOW_PDF.ERROR", exception); } finally { // Gently close streams. close((Closeable) output); } } }
package com.jspsmart.upload;
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("image/jpeg"); pageContext = _jspxFactory.getPageContext( this, request, response, "/myhtml/errorpage/erroe.jsp", true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\r\n"); out.write("\r\n"); out.write('\r'); out.write('\n'); // 设置页é¢ä¸ç¼å response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); // å¨å åä¸å建å¾è±¡ int width = 60, height = 20; BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // è·åå¾å½¢ä¸ä¸æ Graphics g = image.getGraphics(); // çæéæºç±» Random random = new Random(); // 设å®èæ¯è² g.setColor(getRandColor(200, 250)); g.fillRect(0, 0, width, height); // 设å®åä½ g.setFont(new Font("Times New Roman", Font.PLAIN, 18)); // ç»è¾¹æ¡ // g.setColor(new Color()); // g.drawRect(0,0,width-1,height-1); // éæºäº§ç155æ¡å¹²æ°çº¿ï¼ä½¿å¾è±¡ä¸ç认è¯ç ä¸æè¢«å ¶å®ç¨åºæ¢æµå° g.setColor(getRandColor(160, 200)); for (int i = 0; i < 155; i++) { int x = random.nextInt(width); int y = random.nextInt(height); int xl = random.nextInt(12); int yl = random.nextInt(12); g.drawLine(x, y, x + xl, y + yl); } // åéæºäº§çç认è¯ç (4ä½æ°å) String sRand = ""; for (int i = 0; i < 4; i++) { String rand = String.valueOf(random.nextInt(10)); sRand += rand; // å°è®¤è¯ç æ¾ç¤ºå°å¾è±¡ä¸ g.setColor( new Color( 20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110))); // è°ç¨å½æ°åºæ¥çé¢è²ç¸åï¼å¯è½æ¯å // 为ç§å太æ¥è¿ï¼æ以åªè½ç´æ¥çæ g.drawString(rand, 13 * i + 6, 16); } // å°è®¤è¯ç åå ¥SESSION session.setAttribute("rand", sRand); // å¾è±¡çæ g.dispose(); // è¾åºå¾è±¡å°é¡µé¢ ImageIO.write(image, "JPEG", response.getOutputStream()); out.clear(); out = pageContext.pushBody(); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) { } if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); else log(t.getMessage(), t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }
/** Common request handling. */ public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resetState(); boolean success = false; HttpSession session = req.getSession(false); try { this.req = req; this.resp = resp; if (log.isDebug()) { logParams(); } resp.setContentType("text/html"); if (!mayPageBeCached()) { resp.setHeader("pragma", "no-cache"); resp.setHeader("Cache-control", "no-cache"); } reqURL = new URL(UrlUtil.getRequestURL(req)); clientAddr = getLocalIPAddr(); // check that current user has permission to run this servlet if (!isServletAllowed(myServletDescr())) { displayWarningInLieuOfPage("You are not authorized to use " + myServletDescr().heading); return; } // check whether servlet is disabled String reason = ServletUtil.servletDisabledReason(myServletDescr().getServletName()); if (reason != null) { displayWarningInLieuOfPage("This function is disabled. " + reason); return; } if (session != null) { session.setAttribute(SESSION_KEY_RUNNING_SERVLET, getHeading()); String reqHost = req.getRemoteHost(); String forw = req.getHeader(HttpFields.__XForwardedFor); if (!StringUtil.isNullString(forw)) { reqHost += " (proxies for " + forw + ")"; } session.setAttribute(SESSION_KEY_REQUEST_HOST, reqHost); } lockssHandleRequest(); success = (errMsg == null); } catch (ServletException e) { log.error("Servlet threw", e); throw e; } catch (IOException e) { log.error("Servlet threw", e); throw e; } catch (RuntimeException e) { log.error("Servlet threw", e); throw e; } finally { if (session != null) { session.setAttribute(SESSION_KEY_RUNNING_SERVLET, null); session.setAttribute(LockssFormAuthenticator.__J_AUTH_ACTIVITY, TimeBase.nowMs()); } if ("please".equalsIgnoreCase(req.getHeader("X-Lockss-Result"))) { log.debug3("X-Lockss-Result: " + (success ? "Ok" : "Fail")); resp.setHeader("X-Lockss-Result", success ? "Ok" : "Fail"); } resetMyLocals(); resetLocals(); } }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // create the workbook, its worksheet, and its title row Workbook workbook = new HSSFWorkbook(); Sheet sheet = workbook.createSheet("User table"); Row row = sheet.createRow(0); row.createCell(0).setCellValue("The User table"); // create the header row row = sheet.createRow(2); row.createCell(0).setCellValue("UserID"); row.createCell(1).setCellValue("LastName"); row.createCell(2).setCellValue("FirstName"); row.createCell(3).setCellValue("Email"); try { // read database rows ConnectionPool pool = ConnectionPool.getInstance(); Connection connection = pool.getConnection(); Statement statement = connection.createStatement(); String query = "SELECT * FROM User ORDER BY UserID"; ResultSet results = statement.executeQuery(query); // create spreadsheet rows int i = 3; while (results.next()) { row = sheet.createRow(i); row.createCell(0).setCellValue(results.getInt("UserID")); row.createCell(1).setCellValue(results.getString("LastName")); row.createCell(2).setCellValue(results.getString("FirstName")); row.createCell(3).setCellValue(results.getString("Email")); i++; } results.close(); statement.close(); connection.close(); } catch (SQLException e) { this.log(e.toString()); } // set response object headers response.setHeader("content-disposition", "attachment; filename=users.xls"); response.setHeader("cache-control", "no-cache"); // get the output stream String encodingString = request.getHeader("accept-encoding"); OutputStream out; if (encodingString != null && encodingString.contains("gzip")) { out = new GZIPOutputStream(response.getOutputStream()); response.setHeader("content-encoding", "gzip"); // System.out.println("User table encoded with gzip"); } else { out = response.getOutputStream(); // System.out.println("User table not encoded with gzip"); } // send the workbook to the browser workbook.write(out); out.close(); }
// ***************************************************** // Process the initial request from Proshop_main // ***************************************************** // @SuppressWarnings("deprecation") public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // // Prevent caching so sessions are not mangled // resp.setHeader("Pragma", "no-cache"); // for HTTP 1.0 resp.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); // for HTTP 1.1 resp.setDateHeader("Expires", 0); // prevents caching at the proxy server resp.setContentType("text/html"); PrintWriter out = resp.getWriter(); HttpSession session = SystemUtils.verifyPro(req, out); // check for intruder if (session == null) { return; } String club = (String) session.getAttribute("club"); // get club name String templott = (String) session.getAttribute("lottery"); // get lottery support indicator int lottery = Integer.parseInt(templott); // // Call is to display the new features page. // // Display a page to provide a link to the new feature page // out.println("<html><head>"); out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">"); out.println("<meta http-equiv=\"Content-Language\" content=\"en-us\">"); out.println("<title> \"ForeTees Proshop Announcement Page\"</title>"); // out.println("<link rel=\"stylesheet\" href=\"/" +rev+ "/web utilities/foretees.css\" // type=\"text/css\"></link>"); out.println( "<script language=\"JavaScript\" src=\"/" + rev + "/web utilities/foretees.js\"></script>"); out.println("</head>"); out.println("<body bgcolor=\"#FFFFFF\" text=\"#000000\">"); SystemUtils.getProshopSubMenu(req, out, lottery); File f; FileReader fr; BufferedReader br; String tmp = ""; String path = ""; try { path = req.getRealPath(""); tmp = "/proshop_features.htm"; // "/" +rev+ f = new File(path + tmp); fr = new FileReader(f); br = new BufferedReader(fr); if (!f.isFile()) { // do nothing } } catch (FileNotFoundException e) { out.println("<br><br><p align=center>Missing New Features Page.</p>"); out.println("</BODY></HTML>"); out.close(); return; } catch (SecurityException se) { out.println("<br><br><p align=center>Access Denied.</p>"); out.println("</BODY></HTML>"); out.close(); return; } while ((tmp = br.readLine()) != null) out.println(tmp); br.close(); out.println("</BODY></HTML>"); out.close(); } // end of doGet
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try { response.setHeader("Cache-Control", "no-cache"); response.setCharacterEncoding("UTF-8"); String task = request.getParameter("task"); Element data = null; // process help request if (request.getParameter("help") != null) data = getDescription(task); // redirect to home page if there is no task if (data == null && task == null) { response.setContentType("text/html"); response .getWriter() .append( "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"><html><head><meta http-equiv=\"REFRESH\" content=\"0;url=" + context.getInitParameter("server_path") + "></head><body></body></html>"); return; } // process definition request if (data == null && task.equals("define")) { int id = resolveIntegerArg(request.getParameter("id"), -1); int length = resolveIntegerArg(request.getParameter("length"), definer.getDefaultLength()); int format = resolveIntegerArg(request.getParameter("format"), definer.getDefaultFormat()); int maxImageWidth = resolveIntegerArg( request.getParameter("maxImageWidth"), definer.getDefaultMaxImageWidth()); int maxImageHeight = resolveIntegerArg( request.getParameter("maxImageHeight"), definer.getDefaultMaxImageHeight()); int linkDestination = resolveIntegerArg( request.getParameter("linkDestination"), definer.getDefaultLinkDestination()); boolean getImages = resolveBooleanArg(request.getParameter("getImages"), false); data = definer.getDefinition( id, length, format, linkDestination, getImages, maxImageWidth, maxImageHeight); } // all of the remaining tasks require data to be cached, so lets make sure that is finished // before continuing. if (!cachingThread.isOk()) throw new ServletException("Could not cache wikipedia data"); double progress = cachingThread.getProgress(); if (data == null && (progress < 1 || task.equals("progress"))) { // still caching up data, not ready to return a response yet. data = doc.createElement("loading"); data.setAttribute("progress", df.format(progress)); task = "loading"; } // process search request if (data == null && task.equals("search")) { String term = request.getParameter("term"); String id = request.getParameter("id"); int linkLimit = resolveIntegerArg(request.getParameter("linkLimit"), searcher.getDefaultMaxLinkCount()); int senseLimit = resolveIntegerArg( request.getParameter("senseLimit"), searcher.getDefaultMaxSenseCount()); if (id == null) data = searcher.doSearch(term, linkLimit, senseLimit); else data = searcher.doSearch(Integer.parseInt(id), linkLimit); } // process compare request if (data == null && task.equals("compare")) { String term1 = request.getParameter("term1"); String term2 = request.getParameter("term2"); int linkLimit = resolveIntegerArg(request.getParameter("linkLimit"), comparer.getDefaultMaxLinkCount()); boolean details = resolveBooleanArg(request.getParameter("details"), comparer.getDefaultShowDetails()); data = comparer.getRelatedness(term1, term2, details, linkLimit); } // process wikify request if (data == null && task.equals("wikify")) { if (this.wikifier == null) throw new ServletException( "Wikifier is not available. You must configure the servlet so that it has access to link detection and disambiguation models."); String source = request.getParameter("source"); int sourceMode = resolveIntegerArg(request.getParameter("sourceMode"), Wikifier.SOURCE_AUTODETECT); String linkColor = request.getParameter("linkColor"); String baseColor = request.getParameter("baseColor"); double minProb = resolveDoubleArg( request.getParameter("minProbability"), wikifier.getDefaultMinProbability()); int repeatMode = resolveIntegerArg(request.getParameter("repeatMode"), wikifier.getDefaultRepeatMode()); boolean showTooltips = resolveBooleanArg( request.getParameter("showTooltips"), wikifier.getDefaultShowTooltips()); String bannedTopics = request.getParameter("bannedTopics"); boolean wrapInXml = resolveBooleanArg(request.getParameter("wrapInXml"), true); if (wrapInXml) { data = wikifier.wikifyAndWrapInXML( source, sourceMode, minProb, repeatMode, bannedTopics, baseColor, linkColor, showTooltips); } else { response.setContentType("text/html"); response .getWriter() .append( wikifier.wikify( source, sourceMode, minProb, repeatMode, bannedTopics, baseColor, linkColor, showTooltips)); return; } } if (data == null) throw new Exception("Unknown Task"); // wrap data Element wrapper = doc.createElement("WikipediaMinerResponse"); wrapper.setAttribute("server_path", context.getInitParameter("server_path")); wrapper.setAttribute("service_name", context.getInitParameter("service_name")); wrapper.appendChild(data); data = wrapper; // Transform or serialize xml data as appropriate Transformer tf = null; if (request.getParameter("xml") == null) { // we need to transform the data into html tf = transformersByName.get(task); if (request.getParameter("help") != null) tf = transformersByName.get("help"); } if (tf == null) { // we need to serialize the data as xml tf = transformersByName.get("serializer"); response.setContentType("application/xml"); } else { // output will be transformed to html response.setContentType("text/html"); response .getWriter() .append( "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n"); } tf.transform(new DOMSource(data), new StreamResult(response.getWriter())); } catch (Exception error) { response.reset(); response.setContentType("application/xml"); response.setHeader("Cache-Control", "no-cache"); response.setCharacterEncoding("UTF8"); Element xmlError = doc.createElement("Error"); if (error.getMessage() != null) xmlError.setAttribute("message", error.getMessage()); Element xmlStackTrace = doc.createElement("StackTrace"); xmlError.appendChild(xmlStackTrace); for (StackTraceElement ste : error.getStackTrace()) { Element xmlSte = doc.createElement("StackTraceElement"); xmlSte.setAttribute("message", ste.toString()); xmlStackTrace.appendChild(xmlSte); } try { transformersByName .get("serializer") .transform(new DOMSource(xmlError), new StreamResult(response.getWriter())); } catch (Exception e) { // TODO: something for when an error is thrown processing an error???? } ; } }