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); }
private void sendProcessingError(Throwable t, ServletResponse response) { String stackTrace = getStackTrace(t); if (stackTrace != null && !stackTrace.equals("")) { try { response.setContentType("text/html"); PrintStream ps = new PrintStream(response.getOutputStream()); PrintWriter pw = new PrintWriter(ps); pw.print("<html>\n<head>\n</head>\n<body>\n"); // NOI18N // PENDING! Localize this for next official release pw.print("<h1>The resource did not process correctly</h1>\n<pre>\n"); pw.print(stackTrace); pw.print("</pre></body>\n</html>"); // NOI18N pw.close(); ps.close(); response.getOutputStream().close(); ; } catch (Exception ex) { } } else { try { PrintStream ps = new PrintStream(response.getOutputStream()); t.printStackTrace(ps); ps.close(); response.getOutputStream().close(); ; } catch (Exception ex) { } } }
/** Utility method to serialize an exception and its stack trace to simple HTML. */ private final void serializeException(PrintWriter osw, Throwable t) { osw.write("<b>Exception</b>: " + t.toString() + "\n<br/><br/>"); osw.write("<b>Stack trace:</b>"); osw.write( "<pre style=\"margin: 1px solid red; padding: 3px; font-family: sans-serif; font-size: small;\">"); t.printStackTrace(osw); osw.write("</pre>"); }
/** * ************************************************************************ Sends an error to the * client. * * @param t The exception that caused the problem. * @param res The <code>HttpServletResponse</code> for the client. */ public static void handleException(Throwable t, HttpServletResponse res) { try { String message = t.getMessage(); if (message == null) message = "NULL message " + t.getClass().getName(); if (Debug.isSet("trustedMode")) { // security issue: only show stack if trusted ByteArrayOutputStream bs = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(bs); t.printStackTrace(ps); message = new String(bs.toByteArray()); } log.info( UsageLog.closingMessageForRequestContext( HttpServletResponse.SC_BAD_REQUEST, message.length())); log.error("handleException", t); t.printStackTrace(); // debugging - log.error not showing stack trace !! if (!res.isCommitted()) res.sendError(HttpServletResponse.SC_BAD_REQUEST, message); } catch (Throwable e) { log.error("handleException() had problem reporting Exception", e); t.printStackTrace(); } }
/** * (non-Javadoc) * * @see javax.servlet.http.HttpServlet#service(javax.servlet.ServletRequest, * javax.servlet.ServletResponse) */ public void service(ServletRequest _request, ServletResponse _response) throws ServletException, IOException { try { _delegate.service(_request, _response); } catch (Throwable ex) { // Make Sure the Stack Trace is Printed to the Log ex.printStackTrace(); // Set the Data to be Displayed AErrorHandler.setPageErrorData(ex, (HttpServletRequest) _request); // Re-direct to Error Page redirectToErrorPage((HttpServletRequest) _request, (HttpServletResponse) _response); } }
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; }
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException { String retval = "<html> <H4>"; try { // Create a message factory. MessageFactory mf = MessageFactory.newInstance(); // Create a message from the message factory. SOAPMessage msg = mf.createMessage(); // Message creation takes care of creating the SOAPPart - a // required part of the message as per the SOAP 1.1 // specification. SOAPPart sp = msg.getSOAPPart(); // Retrieve the envelope from the soap part to start building // the soap message. SOAPEnvelope envelope = sp.getEnvelope(); // Create a soap header from the envelope. SOAPHeader hdr = envelope.getHeader(); // Create a soap body from the envelope. SOAPBody bdy = envelope.getBody(); // Add a soap body element to the soap body SOAPBodyElement gltp = bdy.addBodyElement( envelope.createName("GetLastTradePrice", "ztrade", "http://wombat.ztrade.com")); gltp.addChildElement(envelope.createName("symbol", "ztrade", "http://wombat.ztrade.com")) .addTextNode("SUNW"); StringBuffer urlSB = new StringBuffer(); urlSB.append(req.getScheme()).append("://").append(req.getServerName()); urlSB.append(":").append(req.getServerPort()).append(req.getContextPath()); String reqBase = urlSB.toString(); if (data == null) { data = reqBase + "/index.html"; } // Want to set an attachment from the following url. // Get context URL url = new URL(data); AttachmentPart ap = msg.createAttachmentPart(new DataHandler(url)); ap.setContentType("text/html"); // Add the attachment part to the message. msg.addAttachmentPart(ap); // Create an endpoint for the recipient of the message. if (to == null) { to = reqBase + "/receiver"; } URL urlEndpoint = new URL(to); System.err.println("Sending message to URL: " + urlEndpoint); System.err.println("Sent message is logged in \"sent.msg\""); retval += " Sent message (check \"sent.msg\") and "; FileOutputStream sentFile = new FileOutputStream("sent.msg"); msg.writeTo(sentFile); sentFile.close(); // Send the message to the provider using the connection. SOAPMessage reply = con.call(msg, urlEndpoint); if (reply != null) { FileOutputStream replyFile = new FileOutputStream("reply.msg"); reply.writeTo(replyFile); replyFile.close(); System.err.println("Reply logged in \"reply.msg\""); retval += " received reply (check \"reply.msg\").</H4> </html>"; } else { System.err.println("No reply"); retval += " no reply was received. </H4> </html>"; } } catch (Throwable e) { e.printStackTrace(); logger.severe("Error in constructing or sending message " + e.getMessage()); retval += " There was an error " + "in constructing or sending message. </H4> </html>"; } try { OutputStream os = resp.getOutputStream(); os.write(retval.getBytes()); os.flush(); os.close(); } catch (IOException e) { e.printStackTrace(); logger.severe("Error in outputting servlet response " + e.getMessage()); } }
public void _jspService( final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException { final javax.servlet.jsp.PageContext pageContext; java.lang.Throwable exception = org.apache.jasper.runtime.JspRuntimeLibrary.getThrowable(request); if (exception != null) { response.setStatus(javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } final javax.servlet.ServletContext application; final javax.servlet.ServletConfig config; javax.servlet.jsp.JspWriter out = null; final java.lang.Object page = this; javax.servlet.jsp.JspWriter _jspx_out = null; javax.servlet.jsp.PageContext _jspx_page_context = null; try { response.setContentType("text/html;charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, false, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); out = pageContext.getOut(); _jspx_out = out; out.write("<!DOCTYPE html>"); out.write("<html>"); out.write("<head>"); out.write("<title>"); out.write("Error"); out.write("</title>"); out.write("<style type=\"text/css\">"); out.write("body{background-color:#202020} body,p{font-family:monospace;color:white}"); out.write("</style>"); out.write("</head>"); out.write("<body>"); out.write("<p>"); out.write("<strong>"); out.write("Error "); out.write( (java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate( "${pageContext.errorData.statusCode}", java.lang.String.class, (javax.servlet.jsp.PageContext) _jspx_page_context, null, false)); out.write("</strong>"); out.write(' '); out.write(':'); out.write(' '); out.write( (java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate( "${pageContext.errorData.requestURI}", java.lang.String.class, (javax.servlet.jsp.PageContext) _jspx_page_context, null, false)); out.write("</p>"); out.write("<p>"); out.write("<pre>"); Throwable t = pageContext.getErrorData().getThrowable(); if (t != null) { t.printStackTrace(new PrintWriter(out)); } out.write("</pre>"); out.write("</p>"); out.write("</body>"); out.write("</html>"); } catch (java.lang.Throwable t) { if (!(t instanceof javax.servlet.jsp.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 throw new ServletException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }
public void performTask(HttpServletRequest request, HttpServletResponse response) { java.sql.Connection con = null; HttpSession ses_usr = null; BeanUtil bu = null; RequestDispatcher dispatcher = null; String strAddress = null; try { ses_usr = request.getSession(false); bu = new BeanUtil(); con = bu.getConn(); bu.setSession(ses_usr); if (!bu.getSessionValues()) throw new Exception( "Por motivos de seguridad la sesi\363n ha expirado\n Registrese nuevamente"); int accion = 1; BeanHelper53 hlp53 = new BeanHelper53(); dbPROVEEDOR proveedor = new dbPROVEEDOR(); dbPROVEEDORs proveedores = new dbPROVEEDORs(); proveedor.setConnection(con); proveedores.setConnection(con); if (request.getParameter("accion") != null) accion = (new Integer(request.getParameter("accion"))).intValue(); int iidproveedor = 0; if (request.getParameter("iidproveedor") != null && !request.getParameter("iidproveedor").equals("")) iidproveedor = (new Integer(request.getParameter("iidproveedor"))).intValue(); int iidcategoria = 0; if (request.getParameter("iidcategoria") != null && !request.getParameter("iidcategoria").equals("")) iidcategoria = (new Integer(request.getParameter("iidcategoria"))).intValue(); int iidgrupo = 0; if (request.getParameter("iidgrupo") != null && !request.getParameter("iidgrupo").equals("")) iidgrupo = (new Integer(request.getParameter("iidgrupo"))).intValue(); int iidlinea = 0; if (request.getParameter("iidlinea") != null && !request.getParameter("iidlinea").equals("")) iidlinea = (new Integer(request.getParameter("iidlinea"))).intValue(); int iidmarca = 0; if (request.getParameter("iidmarca") != null && !request.getParameter("iidmarca").equals("")) iidmarca = (new Integer(request.getParameter("iidmarca"))).intValue(); switch (accion) { case 1: // '\001' { hlp53.getData(con); ses_usr.setAttribute("bean53", hlp53.getBean53()); strAddress = "/jsp/5_3a.jsp"; break; } case 3: // '\003' { dbCLASIFICPROVEEDOR dbCP = new dbCLASIFICPROVEEDOR(); dbPARTEs partes = new dbPARTEs(); dbINVENTARIO inventario = new dbINVENTARIO(); dbCP.setConnection(con); partes.setConnection(con); inventario.setConnection(con); Bean52 bean52 = (Bean52) ses_usr.getAttribute("bean52a"); for (int i = 0; i < bean52.getProveedoresSize(); i++) { if (request.getParameter("C" + bean52.getId(i)) != null) { dbCP.setIidproveedor(bean52.getId(i)); dbCP.setIidcategoria(iidcategoria); dbCP.setIidgrupo(iidgrupo); dbCP.setIidlinea(iidlinea); dbCP.setIidmarca(iidmarca); dbCP.create(); String vchnumparte = Help.getVchnumparte(null, null, null, null); partes.findByPar(iidcategoria, iidgrupo, iidlinea, iidmarca, vchnumparte, false); Vector v = partes.getResult(); for (int j = 0; j < v.size(); j++) { dbPARTE parte = (dbPARTE) v.elementAt(j); inventario.setLiidparte(parte.getLiidparte()); inventario.setIidproveedor(bean52.getId(i)); try { inventario.create(); } catch (Exception exception) { } } } } // fall through } case 2: // '\002' { Bean52 bean52 = new Bean52(); Bean52 bean = new Bean52(); bean52.setVProveedores( proveedores.findByClasificacion(iidcategoria, iidgrupo, iidlinea, iidmarca)); proveedores.findByNotClasificacion(iidcategoria, iidgrupo, iidlinea, iidmarca); bean.setVProveedores(proveedores.getResult()); ses_usr.setAttribute("bean52", bean52); ses_usr.setAttribute("bean52a", bean); strAddress = "/jsp/5_3b.jsp"; break; } case 5: // '\005' { dbCLASIFICPROVEEDOR dbCP = new dbCLASIFICPROVEEDOR(); dbPARTEs partes = new dbPARTEs(); dbINVENTARIO inventario = new dbINVENTARIO(); dbCP.setConnection(con); partes.setConnection(con); inventario.setConnection(con); Bean52 bean52 = (Bean52) ses_usr.getAttribute("bean52"); for (int i = 0; i < bean52.getProveedoresSize(); i++) if (request.getParameter("C" + bean52.getId(i)) != null) { dbCP.setIidproveedor(bean52.getId(i)); dbCP.setIidcategoria(iidcategoria); dbCP.setIidgrupo(iidgrupo); dbCP.setIidlinea(iidlinea); dbCP.setIidmarca(iidmarca); dbCP.remove(); String vchnumparte = Help.getVchnumparte(null, null, null, null); partes.findByPar(iidcategoria, iidgrupo, iidlinea, iidmarca, vchnumparte, false); Vector v = partes.getResult(); for (int j = 0; j < v.size(); j++) { dbPARTE parte = (dbPARTE) v.elementAt(j); inventario.setLiidparte(parte.getLiidparte()); inventario.setIidproveedor(bean52.getId(i)); try { inventario.load(); } catch (Exception exception1) { } if (inventario.getIexistencia() == 0) try { inventario.remove(); } catch (Exception exception2) { } } } // fall through } case 4: // '\004' { Bean52 bean52 = new Bean52(); bean52.setVProveedores( proveedores.findByClasificacion(iidcategoria, iidgrupo, iidlinea, iidmarca)); ses_usr.setAttribute("bean52", bean52); strAddress = "/jsp/5_3c.jsp"; break; } case 7: // '\007' { dbCLASIFICPROVEEDOR dbCP = new dbCLASIFICPROVEEDOR(); dbCP.setConnection(con); Bean53d bean53d = (Bean53d) ses_usr.getAttribute("bean53d"); for (int i = 0; i < bean53d.getProveedoresSize(); i++) { dbCP.setIidproveedor(bean53d.getId(i)); dbCP.setIidcategoria(iidcategoria); dbCP.setIidgrupo(iidgrupo); dbCP.setIidlinea(iidlinea); dbCP.setIidmarca(iidmarca); dbCP.setBitprovefavorito(false); if (iidproveedor == bean53d.getId(i)) dbCP.setBitprovefavorito(true); dbCP.store(); } // fall through } case 6: // '\006' { Bean53d bean53d = new Bean53d(); dbrCLASIFICPROVEEDORs cp = new dbrCLASIFICPROVEEDORs(); cp.setConnection(con); bean53d.setVProveedores( cp.findByClasificacion(iidcategoria, iidgrupo, iidlinea, iidmarca)); ses_usr.setAttribute("bean53d", bean53d); strAddress = "/jsp/5_3d.jsp"; break; } } } catch (Throwable e) { bu.setCommit(false); e.printStackTrace(); BeanError error = new BeanError(); error.setErrorMessage(e.getMessage()); request.setAttribute("error", error); strAddress = "/jsp/error.jsp"; } finally { try { bu.finalizeTransaction(con); dispatcher = getServletContext().getRequestDispatcher(strAddress); dispatcher.forward(request, response); } catch (Exception ex) { System.out.println("FATAL:" + ex.getMessage()); } } }
public void performTask(HttpServletRequest request, HttpServletResponse response) { java.sql.Connection con = null; HttpSession ses_usr = null; BeanUtil bu = null; RequestDispatcher dispatcher = null; String strAddress = null; try { ses_usr = request.getSession(false); bu = new BeanUtil(); con = bu.getConn(); bu.setSession(ses_usr); if (!bu.getSessionValues()) throw new Exception( "Por motivos de seguridad la sesi\363n ha expirado\n Registrese nuevamente"); int accion = 1; dbDESCCARGOSCOMPRA dbDCC = new dbDESCCARGOSCOMPRA(); dbDCC.setConnection(con); dbDESCCARGOSCOMPRAs dbDCCs = new dbDESCCARGOSCOMPRAs(); dbDCCs.setConnection(con); dbPROVEEDORs proveedores = new dbPROVEEDORs(); proveedores.setConnection(con); if (request.getParameter("accion") != null) accion = (new Integer(request.getParameter("accion"))).intValue(); String vchdescripcion = request.getParameter("vchdescripcion"); String vchleyenda = request.getParameter("vchleyenda"); float decfactor = 1.0F; float porcentaje = 0.0F; if (request.getParameter("porcentaje") != null && !request.getParameter("porcentaje").equals("")) { porcentaje = (new Float(request.getParameter("porcentaje"))).floatValue(); decfactor = 1.0F - porcentaje / 100F; } int iidproveedor = 0; if (request.getParameter("iidproveedor") != null && !request.getParameter("iidproveedor").equals("")) iidproveedor = (new Integer(request.getParameter("iidproveedor"))).intValue(); int iidcategoria = 0; if (request.getParameter("iidcategoria") != null && !request.getParameter("iidcategoria").equals("")) iidcategoria = (new Integer(request.getParameter("iidcategoria"))).intValue(); int iidgrupo = 0; if (request.getParameter("iidgrupo") != null && !request.getParameter("iidgrupo").equals("")) iidgrupo = (new Integer(request.getParameter("iidgrupo"))).intValue(); int iidlinea = 0; if (request.getParameter("iidlinea") != null && !request.getParameter("iidlinea").equals("")) iidlinea = (new Integer(request.getParameter("iidlinea"))).intValue(); int iidmarca = 0; if (request.getParameter("iidmarca") != null && !request.getParameter("iidmarca").equals("")) iidmarca = (new Integer(request.getParameter("iidmarca"))).intValue(); float costo = 0.0F; if (request.getParameter("costo") != null && !request.getParameter("costo").equals("")) costo = (new Float(request.getParameter("costo"))).floatValue(); float costoventa = 0.0F; if (request.getParameter("costoventa") != null && !request.getParameter("costoventa").equals("")) costoventa = (new Float(request.getParameter("costoventa"))).floatValue(); dbDCC.setIidproveedor(iidproveedor); dbDCC.setIidcategoria(iidcategoria); dbDCC.setIidgrupo(iidgrupo); dbDCC.setIidlinea(iidlinea); dbDCC.setIidmarca(iidmarca); dbDCC.setVchleyenda(vchdescripcion); dbDCC.setDecfactor(decfactor); dbCLASIFICPROVEEDOR dcCP = new dbCLASIFICPROVEEDOR(); dcCP.setConnection(con); dcCP.setIidproveedor(iidproveedor); dcCP.setIidcategoria(iidcategoria); dcCP.setIidgrupo(iidgrupo); dcCP.setIidlinea(iidlinea); dcCP.setIidmarca(iidmarca); switch (accion) { case 2: // '\002' Bean52 bean52 = new Bean52(); bean52.setVProveedores( proveedores.findByClasificacion(iidcategoria, iidgrupo, iidlinea, iidmarca)); ses_usr.setAttribute("bean52", bean52); strAddress = "/jsp/5_4b.jsp"; break; case 4: // '\004' try { dbDCC.create(); } catch (Exception e) { throw new Exception("No se pudo crear el registro"); } break; case 5: // '\005' dbDCC.setVchleyenda(vchleyenda); dbDCC.load(); dbDCC.setDecfactor(decfactor); dbDCC.store(); break; case 6: // '\006' dbDCC.setVchleyenda(vchleyenda); dbDCC.remove(); break; case 7: // '\007' dbDCC.setVchleyenda("PRONTO PAGO"); try { dbDCC.load(); dbDCC.setDecfactor(decfactor); dbDCC.store(); } catch (SQLException e) { e.printStackTrace(); dbDCC.setDecfactor(decfactor); dbDCC.create(); } break; case 8: // '\b' dcCP.load(); dcCP.setDecfactorvaluainve(costoventa); dcCP.setDecfactorcostovent(1.0F - costo / 100F); dcCP.store(); break; } if (accion == 3 || accion == 4 || accion == 5 || accion == 6 || accion == 7 || accion == 8) { Bean54 bean54 = new Bean54(); dbDCCs.findByPar(iidproveedor, iidcategoria, iidgrupo, iidlinea, iidmarca); dcCP.load(); bean54.setVDesccompra(dbDCCs.getResult()); bean54.setFactorActual(dcCP.getDecfactorcostovent()); bean54.setPorcentajeActual((1.0F - dcCP.getDecfactorcostovent()) * 100F); ses_usr.setAttribute("bean54", bean54); strAddress = "/jsp/5_4c.jsp"; } } catch (Throwable e) { bu.setCommit(false); e.printStackTrace(); BeanError error = new BeanError(); error.setErrorMessage(e.getMessage()); request.setAttribute("error", error); strAddress = "/jsp/error.jsp"; } finally { try { bu.finalizeTransaction(con); dispatcher = getServletContext().getRequestDispatcher(strAddress); dispatcher.forward(request, response); } catch (Exception ex) { System.out.println("FATAL:" + ex.getMessage()); } } }