List of usage examples for java.io PrintWriter print
public void print(Object obj)
From source file:cc.kune.core.server.rack.filters.rest.RESTServiceFilter.java
@Override public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { final String methodName = RackHelper.getMethodName(request, pattern); final ParametersAdapter parameters = new ParametersAdapter(request); LOG.debug("JSON METHOD: '" + methodName + "' on: " + serviceClass.getSimpleName()); response.setCharacterEncoding("utf-8"); final String callbackMethod = getCallbackMethod(request); final boolean isJsonP = isJSONPRequest(callbackMethod); response.setContentType(isJsonP ? "text/javascript" : "text/json"); final RESTResult result = transactionalFilter.doService(serviceClass, methodName, parameters, getInstance(serviceClass));/*w w w.j a v a2 s . co m*/ if (result != null) { if (result.getOutput() != null) { final Object output = wrap(result.getOutput(), isJsonP, callbackMethod); if (output != null) { final PrintWriter writer = response.getWriter(); writer.print(output); writer.flush(); } else { chain.doFilter(request, response); } } else { chain.doFilter(request, response); } } }
From source file:de.jwic.renderer.jsp.JspRenderer.java
public void renderControl(Control control, RenderContext context) { if (log.isDebugEnabled()) { log.debug("Rendering control '" + control.getControlID() + "' with template '" + control.getTemplateName() + "'"); }/* w w w . j a v a 2s . c om*/ String ctrlDivID = "ctrl_" + control.getControlID();//.replace('.', '_'); PrintWriter writer = context.getWriter(); if (!control.isVisible()) { writer.print("<span id=\"" + ctrlDivID + "\">"); writer.print("</span>"); return; } HttpServletRequest request = context.getRequest(); request.setAttribute("control", control); request.setAttribute("jwic", new JWicTools(control.getSessionContext().getLocale(), control.getSessionContext().getTimeZone())); if (control instanceof IControlContainer) { request.setAttribute("insert", new ChildRenderer((IControlContainer) control, context)); } RequestDispatcher dispatcher = context.getRequest() .getRequestDispatcher("/WEB-INF/jwic/jsp/" + control.getTemplateName() + ".jsp"); try { HttpServletResponseFacade res = new HttpServletResponseFacade(context.getResponse(), context.getWriter()); writer.print("<span><span id=\"" + ctrlDivID + "\">"); dispatcher.include(context.getRequest(), res); writer.print("</span></span>"); } catch (Exception e) { log.error("Error including jsp page", e); context.getWriter().write("Error rendering Control (" + e + ")"); } }
From source file:fr.putnami.pwt.plugin.ajaxbot.filter.AjaxPageFilter.java
private InputStream extractHtml(HttpServletRequest request) throws IOException { AjaxPageRenderer crowler = new AjaxPageRenderer(serverUrl); String pageData = crowler.crawlPage(AjaxPageFilter.rewriteQueryString(request.getQueryString())); String cacheFileName = this.getCacheFileName(request.getParameter(QUERY_PARAM_ESCAPED_FRAGMENT)); if (cacheFileName != null) { File cacheFile = new File(cacheFileName); cacheFile.getParentFile().mkdirs(); PrintWriter out = new PrintWriter(cacheFile); out.print(pageData); out.close();//from w ww .jav a 2 s . co m return new FileInputStream(cacheFile); } return new StringInputStream(pageData); }
From source file:me.tfeng.toolbox.dust.NodeEngine.java
private void printIsRegisteredExpression(PrintWriter writer, String template) { writer.print("dust.cache['"); writer.print(StringEscapeUtils.escapeJson(template)); writer.print("'] !== undefined"); }
From source file:de.erdesignerng.test.BaseERDesignerTestCaseImpl.java
protected String statementListToString(StatementList aStatements, SQLGenerator aGenerator) { StringWriter theStringWriter = new StringWriter(); PrintWriter thePrintWriter = new PrintWriter(theStringWriter); for (Statement theStatement : aStatements) { thePrintWriter.print(theStatement.getSql()); thePrintWriter.println(aGenerator.createScriptStatementSeparator()); }// w w w. j a v a 2 s.c om thePrintWriter.flush(); return theStringWriter.toString().trim(); }
From source file:it.cilea.osd.jdyna.web.controller.ExportConfigurazioneSoggettari.java
/** * Metodo di supporto per esportare un soggetto nella sua "bean * definition". //FIXME valutare la possibilita' di utilizzare il * polimorfismo implementando un'interfaccia IExportableBeanDefinition * /*from w w w. j ava2 s .co m*/ * @param writer * @param soggetto */ private void toXML(PrintWriter writer, Soggetto soggetto) { writer.print(" <bean id=\"" + Soggetto.class.getSimpleName() + soggetto.getId() + "\" class=\"" + Soggetto.class.getCanonicalName() + "\">\n"); writer.print(" <property name=\"soggettario\" ref=\"" + Soggettario.class.getSimpleName() + soggetto.getSoggettario().getId() + "\" />\n"); writer.print(" <property name=\"voce\"><value><![CDATA[" + soggetto.getVoce() + "]]></value></property>\n"); writer.print(" </bean>\n\n"); }
From source file:com.concursive.connect.web.webdav.resources.WebdavFolderResource.java
@Override protected void sendContentMenu(final PrintWriter printer) { printer.print("<ul>"); for (WebdavResource r : children) { printer.print("<li><a href='" + r.getHref() + "'>" + r.getName() + "</a>"); }/*from w w w . ja va 2 s . c om*/ printer.print("</ul>"); }
From source file:in.raster.oviyam.servlet.SeriesServlet.java
/** * Handles the HTTP <code>GET</code> method. * @param request servlet request/*from www . ja v a 2s.c o m*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String patID = request.getParameter("patientID"); String studyUID = request.getParameter("studyUID"); String dcmURL = request.getParameter("dcmURL"); SeriesInfo series = new SeriesInfo(); series.callFindWithQuery(patID, studyUID, dcmURL); ArrayList<SeriesModel> seriesList = series.getSeriesList(); Collections.sort(seriesList, new SeriesComparator()); JSONArray jsonArray = new JSONArray(); JSONObject jsonObj = null; try { for (int i = 0; i < seriesList.size(); i++) { SeriesModel sm = (SeriesModel) seriesList.get(i); jsonObj = new JSONObject(); jsonObj.put("seriesUID", sm.getSeriesIUID()); jsonObj.put("seriesNumber", sm.getSeriesNumber()); jsonObj.put("modality", sm.getModality()); jsonObj.put("seriesDesc", sm.getSeriesDescription()); jsonObj.put("bodyPart", sm.getBodyPartExamined()); jsonObj.put("totalInstances", sm.getNumberOfInstances()); jsonObj.put("patientId", patID); jsonObj.put("studyUID", studyUID); jsonArray.put(jsonObj); } PrintWriter out = response.getWriter(); out.print(jsonArray); out.close(); } catch (Exception ex) { log.error(ex); } }
From source file:net.sourceforge.mavenhippo.BeanCreator.java
private void createBean(ContentTypeBean contentType) throws MojoExecutionException { try {/*from w ww . jav a 2 s . c o m*/ String[] packages = generator.getPackage(contentType); String className = generator.getClassName(contentType); File pack = fileManager.getPackage(packages); File classFile = fileManager.getClassFile(pack, className); PrintWriter writer = new PrintWriter(classFile); writer.print(generator.generateBean(contentType)); writer.close(); } catch (ContentTypeException e) { throw new MojoExecutionException(e.getLocalizedMessage(), e); } catch (TemplateException e) { throw new MojoExecutionException(e.getLocalizedMessage(), e); } catch (IOException e) { throw new MojoExecutionException(e.getLocalizedMessage(), e); } }
From source file:de.weltraumschaf.groundzero.opt.commons.CustomHelpFormatter.java
@Override public void printOptions(PrintWriter pw, int width, Options options, int leftPad, int descPad) { super.printOptions(pw, width, options, leftPad, descPad); pw.print(NL); }