public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { OutputStream out = response.getOutputStream(); Connection con = null; Context ctx = null; DataSource ds = null; try { response.setContentType(RESPONSE_CONTENT_TYPE); ctx = new InitialContext(); if (ctx != null) ds = (DataSource) ctx.lookup("java:comp/env/dbpos"); if (ds != null) con = ds.getConnection(); if (con != null) { GoodsExtList glst = PosMinister.getGoodsExtList(con); XMLOutputter outputter = new XMLOutputter(" ", true, "GB2312"); outputter.setTextTrim(true); outputter.output(new Document(glst.toElement()), out); } out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); } finally { DBConnection.closeAll(null, null, con); } }
/** @see com.royalstone.pos.web.command.ICommand#excute(java.lang.Object[]) */ public Object[] excute(Object[] values) { if (values != null && values.length == 3 && (values[1] instanceof String)) { Connection con = null; try { con = DBConnection.getConnection("java:comp/env/dbpos"); Object[] result = new Object[3]; result[0] = getDiscCriteria(con, (String) values[1], (String) values[2]); result[1] = errorMsg1; result[2] = errorMsg2; return result; } finally { DBConnection.closeAll(null, null, con); } } return null; }