Example usage for javax.servlet ServletException printStackTrace

List of usage examples for javax.servlet ServletException printStackTrace

Introduction

In this page you can find the example usage for javax.servlet ServletException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.lainsoft.forge.view.customize.PortletIncluder.java

private void includePortlets(List portlets) {
    try {//from www  .ja v a  2s  .c o  m
        for (int i = 0; i < portlets.size(); i++) {
            pageContext.include(((Portlet) portlets.get(i)).getUri());
        }
    } catch (ServletException se) {
        se.printStackTrace();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}

From source file:com.cabguru.servlet.AddDriverServlet.java

private void dispatch(HttpServletRequest request, HttpServletResponse response, String callerPage, String msg) {

    try {/*from  w  ww .  ja  va 2  s  . c  o  m*/
        request.setAttribute("msg", msg);
        RequestDispatcher rd = request.getRequestDispatcher(callerPage);
        rd.forward(request, response);
    } catch (ServletException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:com.baidu.jprotobuf.rpc.client.ProxyFactoryBeanTestBase.java

protected HttpServer createServer() throws Exception {

    servlet.init();/*from  w  w  w .  j av a  2 s.co m*/

    HttpServerProvider provider = HttpServerProvider.provider();
    HttpServer httpserver = provider.createHttpServer(new InetSocketAddress(8080), 10);

    httpserver.createContext(getPathInfo(), new HttpHandler() {

        @Override
        public void handle(HttpExchange httpExchange) throws IOException {

            MockHttpServletRequest request = new MockHttpServletRequest();
            request.setPathInfo(getPathInfo());

            String queryString = httpExchange.getRequestURI().getRawQuery();

            if (queryString != null) {
                if (queryString.indexOf(ServiceExporter.INPUT_IDL_PARAMETER) != -1) {
                    request.addParameter(ServiceExporter.INPUT_IDL_PARAMETER, "");
                }
                if (queryString.indexOf(ServiceExporter.OUTPUT_IDL_PARAMETER) != -1) {
                    request.addParameter(ServiceExporter.OUTPUT_IDL_PARAMETER, "");
                }
            }

            request.setQueryString(queryString);
            InputStream requestBody = httpExchange.getRequestBody();
            request.setContent(IOUtils.toByteArray(requestBody));

            MockHttpServletResponse response = new MockHttpServletResponse();
            response.setOutputStreamAccessAllowed(true);

            try {
                servlet.service(request, response);
            } catch (ServletException e) {
                e.printStackTrace();
            }
            httpExchange.sendResponseHeaders(200, response.getContentLength());
            OutputStream out = httpExchange.getResponseBody(); // ?
            out.write(response.getContentAsByteArray());
            out.flush();
            httpExchange.close();
        }
    });
    httpserver.setExecutor(null);
    httpserver.start();

    return httpserver;
}

From source file:com.sse.abtester.VariantSelectionFilterTest.java

/**
 * Reinit./* w  w  w .  ja  v a 2s  .c o  m*/
 */
@Before
public void reinit() {
    // make a Mockito mock of the FC so we can verify it gets called
    fc = mock(FilterChain.class);
    mockReq = new MockHttpServletRequest();
    mockReq.setSession(new MockHttpSession());
    mockRes = new MockHttpServletResponse();

    VM = mock(VariantManager.class);
    vsf = new VariantSelectionFilter();
    try {
        vsf.init(new MockFilterConfig());
    } catch (ServletException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    vsf.setVariantManager(VM);
    vsf.setVSKEY(VSKEY);
}

From source file:org.archive.wayback.accesspoint.proxy.AuthProxyConfigSelector.java

public boolean selectConfigHandler(HttpServletRequest request, HttpServletResponse response,
        ProxyAccessPoint proxy) throws IOException {
    response.setStatus(HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED); //407
    response.setHeader("Proxy-Authenticate", "Basic realm=\"" + authMsg + "\"");
    response.setContentType("text/html");

    //TODO: Better way to pass this to jsp?
    request.setAttribute("proxyAccessPoint", proxy);

    StringHttpServletResponseWrapper wrappedResponse = new StringHttpServletResponseWrapper(response);
    RequestDispatcher dispatcher = request.getRequestDispatcher(proxyInfoJsp);

    try {/*from   w  ww. j  a v  a  2 s .co m*/
        dispatcher.forward(request, wrappedResponse);
    } catch (ServletException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    PrintWriter writer = response.getWriter();
    writer.println(wrappedResponse.getStringResponse());
    return true;
}

From source file:net.morphbank.mbsvc3.webservices.RestServiceExcelUpload.java

private void htmlPresentation(HttpServletRequest request, HttpServletResponse response, String folderPath,
        ArrayList<String> reportContent) {
    StringBuffer listOfFiles = new StringBuffer();
    Iterator<String> iter = reportContent.iterator();
    while (iter.hasNext()) {
        String next = iter.next();
        listOfFiles.append(next + "<br />");

    }/*from  w  w w. j  ava2 s. com*/
    if (listOfFiles.length() == 0) {
        listOfFiles.append("No report file found. The upload probably stopped before creating a report.");
    }
    request.setAttribute("listOfFiles", listOfFiles.toString());
    try {
        this.getServletContext().getRequestDispatcher("/showListOfFile.jsp").forward(request, response);
    } catch (ServletException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:org.rti.zcore.dar.report.AppointmentRegister.java

public void getPatientRegister(Date beginDate, Date endDate, int siteId) {

    ResultSet rs = null;//from ww w . ja  va 2 s  .c  om
    // First, get the unique list of patients who visited during the time period in question
    Connection conn = null;
    try {
        conn = ZEPRSUtils.getZEPRSConnection();
    } catch (ServletException e) {
        e.printStackTrace();
    }
    try {
        rs = ZEPRSUtils.getScheduledVisits(beginDate, endDate, siteId, conn);
        // For each patient, load the report class and add this patient to the list
        ArrayList scheduledPatients = new ArrayList();
        while (rs.next()) {
            Long patientId = rs.getLong("patient_id");
            Date appointmentDate = rs.getDate("appointment_date");
            ScheduledPatient scheduledPatient = new ScheduledPatient();
            scheduledPatient.setAppointmentDate(appointmentDate);
            scheduledPatient.setPatientId(patientId);
            scheduledPatient.setDateVisit(appointmentDate);
            // Get the demo info
            try {
                Long encounterId = DemographicsDAO.getDemographicsId(conn, patientId, Long.valueOf(1));
                PatientRegistrationReport encounter = (PatientRegistrationReport) EncountersDAO
                        .getOneReportById(conn, encounterId, new Long("1"), PatientRegistrationReport.class);
                scheduledPatient.setPatientRegistration(encounter);
            } catch (ServletException e) {
                e.printStackTrace();
            } catch (SQLException e) {
                e.printStackTrace();
            } catch (ObjectNotFoundException e) {
                log.error(e);
                e.printStackTrace();
            } catch (NumberFormatException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                log.error(e);
                e.printStackTrace();
            }
            //this.addPatient(scheduledPatient);
            scheduledPatients.add(scheduledPatient);
        }
        rs.close();
        //Collections.sort(scheduledPatients, new DateVisitOrderComparator());
        patients.addAll(scheduledPatients);
    } catch (ServletException e) {
        log.error(e);
        e.printStackTrace();
    } catch (SQLException e) {
        log.error(e);
        e.printStackTrace();
    }

    try {
        conn.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

From source file:com.bluexml.xforms.controller.alfresco.agents.SystemAgent.java

/**
 * /*  ww  w.j  av  a  2s  .c o  m*/
 * @param node
 * @param propertyName
 * @return
 */
public String getNodeProperty(AlfrescoTransaction transaction, NodeRef node, QName propertyName) {
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("serviceName", "NodeService");
    parameters.put("methodName", "getProperty");
    Vector<Object> paramList = new Vector<Object>();
    // add parameters to the method in paramList
    paramList.add(node);
    paramList.add(propertyName);
    parameters.put("methodParams", xstream.toXML(paramList));
    String result;
    try {
        result = (String) xstream
                .fromXML(controller.requestString(transaction, parameters, MsgId.INT_WEBSCRIPT_OPCODE_SERVICE));
    } catch (ServletException e) {
        e.printStackTrace();
        return null;
    }
    return result;
}

From source file:com.bluexml.xforms.controller.alfresco.agents.SystemAgent.java

/**
 * /*w w w. j a v  a 2s. co  m*/
 * @param userName
 * @return
 */
public NodeRef getNodeRefForUser(AlfrescoTransaction transaction, String userName) {
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("serviceName", "AuthorityDAO");
    parameters.put("methodName", "getAuthorityNodeRefOrNull");
    Vector<Object> paramList = new Vector<Object>();
    // add parameters to the method in paramList
    paramList.add(userName);
    parameters.put("methodParams", xstream.toXML(paramList));
    NodeRef result;
    try {
        String resultStr = controller.requestString(transaction, parameters,
                MsgId.INT_WEBSCRIPT_OPCODE_SERVICE);
        result = (NodeRef) xstream.fromXML(resultStr);
    } catch (ServletException e) {
        e.printStackTrace();
        return null;
    }
    return result;
}

From source file:com.bluexml.xforms.controller.alfresco.agents.SystemAgent.java

/**
 * //from  ww  w .  j  av a  2  s  . c o  m
 * @param userName
 * @return
 */
@SuppressWarnings("unchecked")
public Set<String> getContainingGroups(AlfrescoTransaction transaction, String userName) {

    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("serviceName", "AuthorityDAO");
    parameters.put("methodName", "getContainingAuthorities");
    Vector<Object> paramList = new Vector<Object>();
    // add parameters to the method in paramList
    paramList.add(AuthorityType.GROUP);
    paramList.add(userName);
    paramList.add(false);
    parameters.put("methodParams", xstream.toXML(paramList));
    Set<String> result;
    try {
        String resultStr = controller.requestString(transaction, parameters,
                MsgId.INT_WEBSCRIPT_OPCODE_SERVICE);
        result = (Set<String>) xstream.fromXML(resultStr);
    } catch (ServletException e) {
        e.printStackTrace();
        return null;
    }
    return result;
}