Example usage for org.apache.commons.lang StringEscapeUtils escapeHtml

List of usage examples for org.apache.commons.lang StringEscapeUtils escapeHtml

Introduction

In this page you can find the example usage for org.apache.commons.lang StringEscapeUtils escapeHtml.

Prototype

public static String escapeHtml(String input) 

Source Link

Usage

From source file:com.buaa.cfs.conf.ReconfigurationServlet.java

private void printHeader(PrintWriter out, String nodeName) {
    out.print("<html><head>");
    out.printf("<title>%s Reconfiguration Utility</title>%n", StringEscapeUtils.escapeHtml(nodeName));
    out.print("</head><body>\n");
    out.printf("<h1>%s Reconfiguration Utility</h1>%n", StringEscapeUtils.escapeHtml(nodeName));
}

From source file:com.redhat.rhn.frontend.taglibs.RhnHiddenTag.java

/**
 * {@inheritDoc}/*from   w  w w  . j  av  a2s .  co  m*/
 */
@Override
public int doStartTag() throws JspException {
    JspWriter out = null;
    try {
        StringBuffer buf = new StringBuffer();
        out = pageContext.getOut();

        HtmlTag baseTag = new HiddenInputTag();
        if (!StringUtils.isBlank(getId())) {
            baseTag.setAttribute("id", getId());
        }
        baseTag.setAttribute("name", getName());
        baseTag.setAttribute("value", StringEscapeUtils.escapeHtml(getValue()));
        buf.append(baseTag.render());
        out.print(buf.toString());
        return SKIP_BODY;
    } catch (Exception e) {
        throw new JspException("Error writing to JSP file:", e);
    }
}

From source file:de.iteratec.iteraplan.presentation.problemreports.AbstractProblemReportPart.java

public String getEscapedText() {
    Charset charset;//from w w  w. j  a  v  a2s.co m
    try {
        charset = Charset.forName("UTF-8");
    } catch (Exception e) {
        charset = Charset.defaultCharset();
    }
    return StringEscapeUtils.escapeHtml(new String(getByteArray(), charset));
}

From source file:de.suse.swamp.modules.screens.SecureScreen.java

/**
  * Overide this method to perform the security check needed.
  */*  ww  w  .j  a v a2 s  .c  o m*/
  * @param data Turbine information.
  * @return True if the user is authorized to access the screen.
  * @exception Exception a generic exception.
  */
public boolean isAuthorized(RunData data) throws Exception {
    boolean isAuthorized = false;

    if (data.getUser().hasLoggedIn()) {
        isAuthorized = true;
    } else {
        // this url the user wants to see, but he has no right to.
        HttpServletRequest req = data.getParameters().getRequest();
        StringBuffer query = new StringBuffer();
        for (int i = 0; i < data.getParameters().getKeys().length; i++) {
            String key = (String) data.getParameters().getKeys()[i];
            query.append(key).append("=").append(StringEscapeUtils.escapeHtml(data.getParameters().get(key)))
                    .append("&");
        }

        // set a message 
        if (data.getMessage() == null && !query.toString().equals("template=Index.vm&")) {
            data.setMessage("You need to login for viewing the requested page.<br />"
                    + "After login you will get redirected there.");
        }
        // forwarding to login page and setting parameter for coming back
        data.setScreen(Turbine.getConfiguration().getString("screen.login"));
        data.setScreenTemplate(Turbine.getConfiguration().getString("template.login"));
        data.setLayoutTemplate("DefaultLayout.vm");

        data.getUser().setTemp("query", req.getRequestURL().append("?").append(query));
        isAuthorized = false;
    }
    return isAuthorized;
}

From source file:au.edu.ausstage.exchange.types.Venue.java

public String toHtml() {

    StringBuilder builder = new StringBuilder("<li>");

    builder.append("<a href=\"" + url + "\" title=\"View this record in AusStage\">"
            + StringEscapeUtils.escapeHtml(name) + "</a>");
    builder.append(", " + StringEscapeUtils.escapeHtml(address));
    builder.append("</li>");

    return builder.toString();
}

From source file:com.fluidops.iwb.ui.templates.ServletPageParameters.java

public static ServletPageParameters computePageParameter(PageContext pc) {
    PrinterExtensions printerExtensions = Global.printerExtension;
    UserManager userManager = EndpointImpl.api().getUserManager();

    ServletPageParameters p = new ServletPageParameters();
    p.pc = pc;/*  ww  w.jav  a  2 s  .c  o m*/
    p.pageTitle = pc.title;
    p.prefixedPageTitle = Config.getConfig().getTitlePrefix() == null ? pc.title
            : StringEscapeUtils.escapeHtml(Config.getConfig().getTitlePrefix()) + " " + pc.title;
    p.htmlHead = PrinterImpl.computeHtmlHead(pc);
    p.userScript = printerExtensions.getUserScript();
    p.contextPath = EndpointImpl.api().getRequestMapper().getContextPath();
    // the actual page container, might be null (e.g. for SPARQL interface we don't need it)
    p.body = pc.container != null ? pc.container.getContainer().htmlAnchor().toString() : "";
    p.toolBarButtons = printerExtensions.addToolbarButtons(pc, p.htmlHead);
    p.userUri = userManager.getUserURI(null);
    p.userName = userManager.getUserName(null);
    p.loggedIn = userManager.isLoggedIn(null) ? "true" : null;
    p.roleString = printerExtensions.getRoleString();
    // for non-resource based pages we assume read access by default
    p.hasReadAccess = pc.value != null ? userManager.hasValueAccess(pc.value, ValueAccessLevel.READ) : true;
    p.searchInput = new SearchTextInput("searchInput" + Rand.getIncrementalFluidUUID(), p.contextPath);
    ;

    // configure the default value for the search box, if required
    // i.e. if the current page is from the search page
    if (pc instanceof SearchPageContext) {
        configureSearchInput((SearchPageContext) pc, p.searchInput);
    }

    pc.page.register(p.searchInput);

    // top menubar and lower menubar
    p.topMenuBar = renderTopMenuBar(printerExtensions, p);
    p.lowerMenuBar = renderLowerMenuBar(printerExtensions, p);

    return p;
}

From source file:com.redhat.rhn.frontend.dto.MultiOrgAllUserOverview.java

/**
 * get the user's last name
 * @return the user's last name
 */
public String getUserLastName() {
    return StringEscapeUtils.escapeHtml(userLastName);
}

From source file:co.cask.cdap.logging.gateway.handlers.TextChunkedLogProducer.java

@Override
protected ChannelBuffer writeLogEvents(CloseableIterator<LogEvent> logEventIter) throws IOException {
    channelBuffer.clear();/* w w w . j  av  a2 s .  c  om*/
    while (logEventIter.hasNext() && channelBuffer.readableBytes() < BUFFER_BYTES) {
        LogEvent logEvent = logEventIter.next();
        String logLine = patternLayout.doLayout(logEvent.getLoggingEvent());
        logLine = escape ? StringEscapeUtils.escapeHtml(logLine) : logLine;
        channelBuffer.writeBytes(Bytes.toBytes(logLine));
    }
    return channelBuffer;
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.manager.student.CalendarDebugDA.java

@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    String info = request.getParameter("user");
    if (info != null) {
        User u = User.findByUsername(info);
        HashMap<Registration, String> hm = new HashMap<>();
        if (u.getPerson().getStudent() != null) {
            for (Registration registration : u.getPerson().getStudent().getActiveRegistrations()) {
                hm.put(registration,//w  w w.jav  a 2s  . c o  m
                        "<b>Classes: </b>"
                                + StringEscapeUtils.escapeHtml(
                                        ICalStudentTimeTable.getUrl("syncClasses", registration, request))
                                + "<br/>" + "<b>Exams: </b>"
                                + StringEscapeUtils.escapeHtml(
                                        ICalStudentTimeTable.getUrl("syncExams", registration, request))
                                + "<br/>");
            }
        }
        request.setAttribute("list", hm);
    } else {
        info = "";
    }

    request.setAttribute("user", info);
    return mapping.findForward("CalendarData");
}

From source file:com.bstek.dorado.view.output.OutputUtils.java

/**
 * ??HTML/*  ww  w  .jav  a 2 s.  c  o  m*/
 * 
 * @throws IOException
 */
public static void outputString(Writer writer, String s) throws IOException {
    writer.write(StringEscapeUtils.escapeHtml(s));
}