Java Code Examples for org.apache.commons.lang.StringEscapeUtils.escapeHtml()

The following are Jave code examples for showing how to use escapeHtml() of the org.apache.commons.lang.StringEscapeUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: visuflow-plugin   File: GraphManager.java   View Source Code Vote up 6 votes
/**
 * Creates the graph method node and sets the label, methodName, methodSignature, methodBody and nodeMethod attributes on the node.
 *
 * @param src
 * @author Shashank B S
 */
private void createGraphMethodNode(VFMethod src) {
	if (graph.getNode(src.getId() + "") == null) {
		Node createdNode = graph.addNode(src.getId() + "");
		String methodName = src.getSootMethod().getName();
		String escapedMethodName = StringEscapeUtils.escapeHtml(methodName);
		String escapedMethodSignature = StringEscapeUtils.escapeHtml(src.getSootMethod().getSignature());
		createdNode.setAttribute("ui.label", methodName);
		createdNode.setAttribute("nodeData.methodName", escapedMethodName);
		createdNode.setAttribute("nodeData.methodSignature", escapedMethodSignature);
		String methodBody = src.getBody().toString();
		methodBody = Pattern.compile("^[ ]{4}", Pattern.MULTILINE).matcher(methodBody).replaceAll(""); // remove indentation at line start
		methodBody = methodBody.replaceAll("\n{2,}", "\n"); // replace empty lines
		String escapedMethodBody = StringEscapeUtils.escapeHtml(methodBody);
		String hexColor = getCodeBackgroundColor();
		createdNode.setAttribute("nodeData.methodBody", "<code><pre style=\"color: #000000; background-color: #"+hexColor+"\">" + escapedMethodBody + "</pre></code>");
		createdNode.setAttribute("nodeMethod", src);
	}
}
 
Example 2
Project: hadoop   File: GetJournalEditServlet.java   View Source Code Vote up 6 votes
private boolean checkStorageInfoOrSendError(JNStorage storage,
    HttpServletRequest request, HttpServletResponse response)
    throws IOException {
  int myNsId = storage.getNamespaceID();
  String myClusterId = storage.getClusterID();
  
  String theirStorageInfoString = StringEscapeUtils.escapeHtml(
      request.getParameter(STORAGEINFO_PARAM));

  if (theirStorageInfoString != null) {
    int theirNsId = StorageInfo.getNsIdFromColonSeparatedString(
        theirStorageInfoString);
    String theirClusterId = StorageInfo.getClusterIdFromColonSeparatedString(
        theirStorageInfoString);
    if (myNsId != theirNsId || !myClusterId.equals(theirClusterId)) {
      String msg = "This node has namespaceId '" + myNsId + " and clusterId '"
          + myClusterId + "' but the requesting node expected '" + theirNsId
          + "' and '" + theirClusterId + "'";
      response.sendError(HttpServletResponse.SC_FORBIDDEN, msg);
      LOG.warn("Received an invalid request file transfer request from " +
          request.getRemoteAddr() + ": " + msg);
      return false;
    }
  }
  return true;
}
 
Example 3
Project: BUbiNG   File: NamedGraphServerHttpProxy.java   View Source Code Vote up 6 votes
public static void generate(final long hashCode, final StringBuilder content, final CharSequence[] successors, boolean notescurl) {
	content.append("<html>\n<head></head>\n<body>\n");
	// This helps in making the page text different even for the same number
	// of URLs, but not always.
	content.append("<h1>").append((char)((hashCode & 0xF) + 'A')).append((char)((hashCode >>> 4 & 0xF) + 'A')).append((char)((hashCode >>> 8 & 0xF) + 'A')).append((char)((hashCode >>> 12 & 0xF) + 'A')).append("</h1>\n");
	for (final CharSequence s : successors) {
		String ref = s.toString();
		if (!notescurl) ref = StringEscapeUtils.escapeHtml(s.toString());
		content.append("<p>Lorem ipsum dolor sit amet <a href=\""
				+ ref
				+ "\">"
				+ ref
				+ "</a>, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n");
	}
	content.append("</body>\n</html>\n");
}
 
Example 4
Project: lams   File: GBUserGridRowDTO.java   View Source Code Vote up 5 votes
public GBUserGridRowDTO(User user) {
this.id = user.getUserId().toString();
this.rowName = StringEscapeUtils.escapeHtml(user.getLastName() + " " + user.getFirstName());
this.firstName = user.getFirstName();
this.lastName = user.getLastName();
this.login = user.getLogin();
this.setPortraitId(user.getPortraitUuid());
   }
 
Example 5
Project: lams   File: GradebookService.java   View Source Code Vote up 5 votes
/**
    * Returns the activity status string which is a reference to an image
    *
    * @param learnerProgress
    * @param activity
    * @return
    */
   private String getActivityStatusStr(LearnerProgress learnerProgress, Activity activity) {

final String IMAGES_DIR = Configuration.get(ConfigurationKeys.SERVER_URL) + "images";
if (learnerProgress != null) {
    byte statusByte = learnerProgress.getProgressState(activity);
    if (statusByte == LearnerProgress.ACTIVITY_ATTEMPTED && learnerProgress.getCurrentActivity() != null) {
	return "<i class='fa fa-cog' title='"
		+ StringEscapeUtils.escapeHtml(learnerProgress.getCurrentActivity().getTitle()) + "'></i>";
    } else if (statusByte == LearnerProgress.ACTIVITY_COMPLETED) {
	return "<i class='fa fa-check text-success'></i>";
    }
}
return "-";
   }
 
Example 6
Project: lams   File: QaMonitoringAction.java   View Source Code Vote up 5 votes
/**
    * Get Paged Reflections
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   public ActionForward getReflectionsJSON(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws IOException, ServletException, ToolException, JSONException {

Long toolSessionId = WebUtil.readLongParam(request, QaAppConstants.TOOL_SESSION_ID);

// paging parameters of tablesorter
int size = WebUtil.readIntParam(request, "size");
int page = WebUtil.readIntParam(request, "page");
Integer sortByName = WebUtil.readIntParam(request, "column[0]", true);
String searchString = request.getParameter("fcol[0]");

int sorting = QaAppConstants.SORT_BY_NO;
if (sortByName != null) {
    sorting = sortByName.equals(0) ? QaAppConstants.SORT_BY_USERNAME_ASC : QaAppConstants.SORT_BY_USERNAME_DESC;
}

//return user list according to the given sessionID
IQaService qaService = getQAService();
List<Object[]> users = qaService.getUserReflectionsForTablesorter(toolSessionId, page, size, sorting,
	searchString);

JSONArray rows = new JSONArray();
JSONObject responsedata = new JSONObject();
responsedata.put("total_rows", qaService.getCountUsersBySessionWithSearch(toolSessionId, searchString));

for (Object[] userAndReflection : users) {
    JSONObject responseRow = new JSONObject();
    responseRow.put("username", StringEscapeUtils.escapeHtml((String) userAndReflection[1]));
    if (userAndReflection.length > 2 && userAndReflection[2] != null) {
	String reflection = StringEscapeUtils.escapeHtml((String) userAndReflection[2]);
	responseRow.put(QaAppConstants.NOTEBOOK, reflection.replaceAll("\n", "<br>"));
    }
    rows.put(responseRow);
}
responsedata.put("rows", rows);
response.setContentType("application/json;charset=utf-8");
response.getWriter().print(new String(responsedata.toString()));
return null;
   }
 
Example 7
Project: jbake-rtl-jalaali   File: JadeTemplateEngine.java   View Source Code Vote up 4 votes
public String escape(String s) {
    return StringEscapeUtils.escapeHtml(s);
}
 
Example 8
Project: shop-manager   File: XssHttpServletRequestWrapper.java   View Source Code Vote up 4 votes
@Override    
public String getHeader(String name) {    
    return StringEscapeUtils.escapeHtml(super.getHeader(name));    
}
 
Example 9
Project: shop-manager   File: XssHttpServletRequestWrapper.java   View Source Code Vote up 4 votes
@Override    
public String getParameter(String name) {    
    return StringEscapeUtils.escapeHtml(super.getParameter(name));    
}
 
Example 10
Project: visuflow-plugin   File: GraphManager.java   View Source Code Vote up 4 votes
/**
 * Creates the CFG node and sets the label, unit, escapedHTMLunit, unitType, inSet, outSet, color attributes.
 *
 * @param node
 * @author Shashank B S
 */
private void createControlFlowGraphNode(VFNode node) {
	if (graph.getNode(node.getId() + "") == null) {
		Node createdNode = graph.addNode(node.getId() + "");
		Unit unit = node.getUnit();
		String label = unit.toString();
		try {
			UnitFormatter formatter = UnitFormatterFactory.createFormatter(unit);
			//UnitFormatter formatter = new DefaultFormatter();
			label = formatter.format(unit, maxLength);
		} catch (Exception e) {
			logger.error("Unit formatting failed", e);
		}

		createdNode.setAttribute("ui.label", label);
		String str = unit.toString();
		String escapedNodename = StringEscapeUtils.escapeHtml(str);
		createdNode.setAttribute("unit", str);
		createdNode.setAttribute("nodeData.unit", escapedNodename);

		createdNode.setAttribute("nodeData.unitType", node.getUnit().getClass());
		String str1 = Optional.fromNullable(node.getVFUnit().getInSet()).or("n/a").toString();
		String nodeInSet = StringEscapeUtils.escapeHtml(str1);
		String str2 = Optional.fromNullable(node.getVFUnit().getOutSet()).or("n/a").toString();
		String nodeOutSet = StringEscapeUtils.escapeHtml(str2);

		createdNode.setAttribute("nodeData.inSet", nodeInSet);
		createdNode.setAttribute("nodeData.outSet", nodeOutSet);

		Map<String, String> customAttributes = node.getVFUnit().getHmCustAttr();
		String attributeData = "";
		if(!customAttributes.isEmpty())
		{
			Iterator<Entry<String, String>> customAttributeIterator = customAttributes.entrySet().iterator();
			while(customAttributeIterator.hasNext())
			{
				Entry<String, String> curr = customAttributeIterator.next();
				attributeData += curr.getKey() + " : " + curr.getValue();
				attributeData += "<br />";
			}
			createdNode.setAttribute(nodeAttributesString, attributeData);
		}

		createdNode.setAttribute("nodeUnit", node);
		Color nodeColor = new Color(new ProjectPreferences().getColorForNode(node.getUnit().getClass().getName().toString()));
		createdNode.addAttribute("ui.color", nodeColor);
	}
}
 
Example 11
Project: Equella   File: DirListViewer.java   View Source Code Vote up 4 votes
private void viewDirList(ViewItemResource resource, FileHandle fileHandle, HttpServletResponse response)
	throws IOException
{
	final String dirPath = resource.getFileDirectoryPath();

	response.setContentType("text/html");

	try (PrintWriter writer = new PrintWriter(new PrintStream(response.getOutputStream())))
	{
		writer.print("<html><head></head><body><h1>");
		writer.print(CurrentLocale.get("viewitem.section.dirlistsection.tle"));
		writer.print("</h1><b>");
		writer.print(CurrentLocale.get("viewitem.section.dirlistsection.listing",
			StringEscapeUtils.escapeHtml(resource.getViewableItem().getItemdir() + dirPath)));
		writer.print("</b><ul id=\"listing\">\n");

		if( dirPath.length() == 0 )
		{
			String xml = StringEscapeUtils.escapeHtml(XML_NAME);
			writer.print("<li><a href=\"");
			writer.print(xml);
			writer.print("\">");
			writer.print(xml);
			writer.print("</a></li>\n");
		}

		FileEntry[] aszFileList = fileSystemService.enumerate(fileHandle, dirPath, null);
		if( !Check.isEmpty(aszFileList) )
		{
			for( FileEntry entry : aszFileList )
			{
				String szFile = entry.getName();
				szFile = URLUtils.urlEncode(szFile, false);
				String name = szFile;
				if( entry.isFolder() )
				{
					szFile += "/~";
				}
				writer.print("<li><a href=\"");
				writer.print(szFile);
				writer.print("\">");
				writer.print(name);
				writer.print("</a></li>");
			}
		}
		writer.print("</ul></body></html>");
	}
}
 
Example 12
Project: lams   File: MonitoringAction.java   View Source Code Vote up 4 votes
private ActionForward getAnswersJSON(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws JSONException, IOException {

Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);
Long questionUid = WebUtil.readLongParam(request, SurveyConstants.ATTR_QUESTION_UID);

// paging parameters of tablesorter
int size = WebUtil.readIntParam(request, "size");
int page = WebUtil.readIntParam(request, "page");
Integer sortByName = WebUtil.readIntParam(request, "column[0]", true);
String searchString = request.getParameter("fcol[0]");

int sorting = SurveyConstants.SORT_BY_DEAFAULT;
if (sortByName != null) {
    sorting = sortByName.equals(0) ? SurveyConstants.SORT_BY_NAME_ASC : SurveyConstants.SORT_BY_NAME_DESC;
}

// return user list according to the given sessionID
ISurveyService service = getSurveyService();
SurveyQuestion question = service.getQuestion(questionUid);
List<Object[]> users = service.getQuestionAnswersForTablesorter(sessionId, questionUid, page, size, sorting,
	searchString);

JSONArray rows = new JSONArray();
JSONObject responsedata = new JSONObject();
responsedata.put("total_rows", service.getCountUsersBySession(sessionId, searchString));

for (Object[] userAndAnswers : users) {

    JSONObject responseRow = new JSONObject();

    SurveyUser user = (SurveyUser) userAndAnswers[0];
    responseRow.put(SurveyConstants.ATTR_USER_NAME,
	    StringEscapeUtils.escapeHtml(user.getLastName() + " " + user.getFirstName()));
    responseRow.put(SurveyConstants.ATTR_USER_ID, user.getUserId());

    if (userAndAnswers.length > 1 && userAndAnswers[1] != null) {
	responseRow.put("choices", SurveyWebUtils.getChoiceList((String) userAndAnswers[1]));
    }
    if (userAndAnswers.length > 2 && userAndAnswers[2] != null) {
	// Data is handled differently in learner depending on whether
	// it is an extra text added
	// to a multiple choice, or a free text entry. So need to handle
	// the output differently.
	// See learner/result.jsp and its handling of question.type == 3
	// vs question.appendText
	String answer;
	if (question.getType() == SurveyConstants.QUESTION_TYPE_TEXT_ENTRY) {
	    // don't escape as it was escaped & BR'd before saving
	    answer = (String) userAndAnswers[2];
	} else {
	    // need to escape it, as it isn't escaped in the database
	    answer = StringEscapeUtils.escapeHtml((String) userAndAnswers[2]);
	    answer = answer.replaceAll("\n", "<br>");
	}
	responseRow.put("answerText", answer);
    }
    if (userAndAnswers.length > 3 && userAndAnswers[3] != null) {
	responseRow.put(SurveyConstants.ATTR_PORTRAIT_ID, ((Number)userAndAnswers[3]).longValue());
    }
    rows.put(responseRow);
}
responsedata.put("rows", rows);
response.setContentType("application/json;charset=utf-8");
response.getWriter().print(new String(responsedata.toString()));
return null;
   }
 
Example 13
Project: lams   File: MonitoringAction.java   View Source Code Vote up 4 votes
private ActionForward getReflectionsJSON(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws JSONException, IOException {

Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);

// paging parameters of tablesorter
int size = WebUtil.readIntParam(request, "size");
int page = WebUtil.readIntParam(request, "page");
Integer sortByName = WebUtil.readIntParam(request, "column[0]", true);
String searchString = request.getParameter("fcol[0]");

int sorting = SurveyConstants.SORT_BY_DEAFAULT;
if (sortByName != null) {
    sorting = sortByName.equals(0) ? SurveyConstants.SORT_BY_NAME_ASC : SurveyConstants.SORT_BY_NAME_DESC;
}

// return user list according to the given sessionID
ISurveyService service = getSurveyService();
List<Object[]> users = service.getUserReflectionsForTablesorter(sessionId, page, size, sorting, searchString);

JSONArray rows = new JSONArray();
JSONObject responsedata = new JSONObject();
responsedata.put("total_rows", service.getCountUsersBySession(sessionId, searchString));

for (Object[] userAndReflection : users) {

    JSONObject responseRow = new JSONObject();

    SurveyUser user = (SurveyUser) userAndReflection[0];
    responseRow.put(SurveyConstants.ATTR_USER_NAME,
	    StringEscapeUtils.escapeHtml(user.getLastName() + " " + user.getFirstName()));
    responseRow.put(SurveyConstants.ATTR_USER_ID, user.getUserId());
    
    if (userAndReflection.length > 1 && userAndReflection[1] != null) {
	String reflection = StringEscapeUtils.escapeHtml((String) userAndReflection[1]);
	responseRow.put(SurveyConstants.ATTR_REFLECTION, reflection.replaceAll("\n", "<br>"));
    }

    if (userAndReflection.length > 2 && userAndReflection[2] != null) {
	responseRow.put(SurveyConstants.ATTR_PORTRAIT_ID, ((Number)userAndReflection[2]).longValue());
    }

    rows.put(responseRow);
}
responsedata.put("rows", rows);
response.setContentType("application/json;charset=utf-8");
response.getWriter().print(new String(responsedata.toString()));
return null;
   }
 
Example 14
Project: lams   File: GBLessonGridRowDTO.java   View Source Code Vote up 4 votes
@Override
   public ArrayList<String> toStringArray(GBGridView view) {
ArrayList<String> ret = new ArrayList<String>();

ret.add(id.toString());

rowName = StringEscapeUtils.escapeHtml(rowName);

if (view == GBGridView.MON_COURSE) {
    if (gradebookMonitorURL != null && gradebookMonitorURL.length() != 0) {
	ret.add("<a href='javascript:launchPopup(\"" + gradebookMonitorURL + "\",\"" + rowName
		+ "\",1220,600)'>" + rowName + "</a>");
    } else {
	ret.add(rowName);
    }
    ret.add(subGroup);
    ret.add(startDate != null ? convertDateToString(startDate, null) : CELL_EMPTY);
    ret.add((medianTimeTaken != null && medianTimeTaken != 0) ? convertTimeToString(medianTimeTaken)
	    : CELL_EMPTY);
    ret.add((averageMark != null) ? GradebookUtil.niceFormatting(averageMark, displayMarkAsPercent) : CELL_EMPTY);

} else if ((view == GBGridView.LRN_COURSE) || (view == GBGridView.MON_USER)) {
    if (gradebookLearnerURL != null && gradebookLearnerURL.length() != 0) {
	ret.add("<a href='javascript:launchPopup(\"" + gradebookLearnerURL + "\",\"" + rowName + "\",796,570)'>"
		+ rowName + "</a>");
    } else {
	ret.add(rowName);
    }
    ret.add(subGroup);
    ret.add((status != null) ? status : CELL_EMPTY);
    ret.add(startDate != null ? convertDateToString(startDate, null) : CELL_EMPTY);
    ret.add(finishDate != null ? convertDateToString(finishDate, null) : CELL_EMPTY);
    ret.add(feedback);
    ret.add((medianTimeTaken != null && medianTimeTaken != 0)
	    ? toItalic(convertTimeToString(medianTimeTaken)) : CELL_EMPTY);
    ret.add((timeTaken != null) ? convertTimeToString(timeTaken) : CELL_EMPTY);
    ret.add((averageMark != null) ? toItalic(GradebookUtil.niceFormatting(averageMark, displayMarkAsPercent)) : CELL_EMPTY);
    ret.add((mark != null) ? GradebookUtil.niceFormatting(mark, displayMarkAsPercent) : CELL_EMPTY);

    //plain lesson list case
} else if (view == GBGridView.LIST) {
    ret.add(rowName);
}
return ret;
   }
 
Example 15
Project: DWSurvey   File: EncodeUtils.java   View Source Code Vote up 4 votes
/**
 * Html 转码.
 */
public static String htmlEscape(String html) {
	return StringEscapeUtils.escapeHtml(html);
}
 
Example 16
Project: lams   File: MonitoringAction.java   View Source Code Vote up 4 votes
private ActionForward getSubgridData(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws JSONException, IOException {
IResourceService service = getResourceService();

Long itemUid = WebUtil.readLongParam(request, ResourceConstants.ATTR_RESOURCE_ITEM_UID);
Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);

// Getting the params passed in from the jqGrid
int page = WebUtil.readIntParam(request, AttributeNames.PARAM_PAGE);
int rowLimit = WebUtil.readIntParam(request, AttributeNames.PARAM_ROWS);
String sortOrder = WebUtil.readStrParam(request, AttributeNames.PARAM_SORD);
String sortBy = WebUtil.readStrParam(request, AttributeNames.PARAM_SIDX, true);
if (StringUtils.isEmpty(sortBy)) {
    sortBy = "userName";
}
String searchString = WebUtil.readStrParam(request, "userName", true);

List<VisitLogDTO> visitLogDtos = service.getPagedVisitLogsBySessionAndItem(sessionId, itemUid, page - 1,
	rowLimit, sortBy, sortOrder, searchString);
int countVisitLogs = service.getCountVisitLogsBySessionAndItem(sessionId, itemUid, searchString);

int totalPages = new Double(
	Math.ceil(new Integer(countVisitLogs).doubleValue() / new Integer(rowLimit).doubleValue())).intValue();

JSONArray rows = new JSONArray();
DateFormat timeTakenFormatter = new SimpleDateFormat("H:mm:ss");
DateFormat dateFormatter = new SimpleDateFormat("d-MMM-yyyy h:mm a");
HttpSession ss = SessionManager.getSession();
UserDTO learnerDto = (UserDTO) ss.getAttribute(AttributeNames.USER);
TimeZone monitorTimeZone = learnerDto.getTimeZone();
int i = 1;
for (VisitLogDTO visitLogDto : visitLogDtos) {

    JSONArray visitLogData = new JSONArray();
    visitLogData.put(visitLogDto.getUserId());
    String fullName = StringEscapeUtils.escapeHtml(visitLogDto.getUserFullName());
    visitLogData.put(fullName);
    String accessDate = (visitLogDto.getAccessDate() == null) ? ""
	    : dateFormatter.format(
		    DateUtil.convertToTimeZoneFromDefault(monitorTimeZone, visitLogDto.getAccessDate()));
    visitLogData.put(accessDate);
    String completeDate = (visitLogDto.getCompleteDate() == null) ? ""
	    : dateFormatter.format(
		    DateUtil.convertToTimeZoneFromDefault(monitorTimeZone, visitLogDto.getCompleteDate()));
    visitLogData.put(completeDate);
    String timeTaken = (visitLogDto.getTimeTaken() == null) ? ""
	    : timeTakenFormatter.format(visitLogDto.getTimeTaken());
    visitLogData.put(timeTaken);
    visitLogData.put(visitLogDto.getPortraitId());

    JSONObject userRow = new JSONObject();
    userRow.put("id", i++);
    userRow.put("cell", visitLogData);

    rows.put(userRow);
}

JSONObject responseJSON = new JSONObject();
responseJSON.put("total", totalPages);
responseJSON.put("page", page);
responseJSON.put("records", countVisitLogs);
responseJSON.put("rows", rows);

response.setContentType("application/json;charset=utf-8");
response.getWriter().write(responseJSON.toString());
return null;
   }
 
Example 17
Project: lams   File: MonitoringAction.java   View Source Code Vote up 4 votes
public ActionForward getReflectionsJSON(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws IOException, ServletException, ToolException, JSONException {

Long sessionUid = WebUtil.readLongParam(request, VoteAppConstants.ATTR_SESSION_UID, true);

// paging parameters of tablesorter
int size = WebUtil.readIntParam(request, "size");
int page = WebUtil.readIntParam(request, "page");
Integer sortByName = WebUtil.readIntParam(request, "column[0]", true);
String searchString = request.getParameter("fcol[0]");

int sorting = VoteAppConstants.SORT_BY_DEFAULT;
if (sortByName != null) {
    sorting = sortByName.equals(0) ? VoteAppConstants.SORT_BY_NAME_ASC : VoteAppConstants.SORT_BY_NAME_DESC;
}

//return user list according to the given sessionID
IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
List<Object[]> users = voteService.getUserReflectionsForTablesorter(sessionUid, page, size, sorting,
	searchString);

JSONArray rows = new JSONArray();
JSONObject responsedata = new JSONObject();
responsedata.put("total_rows", voteService.getCountUsersBySession(sessionUid, null, searchString));

for (Object[] userAndReflection : users) {
    JSONObject responseRow = new JSONObject();
    responseRow.put(VoteAppConstants.ATTR_USER_ID, userAndReflection[0]);
    responseRow.put(VoteAppConstants.ATTR_USER_NAME,
	    StringEscapeUtils.escapeHtml((String) userAndReflection[2]));
    if (userAndReflection.length > 3 && userAndReflection[3] != null) {
	String reflection = StringEscapeUtils.escapeHtml((String) userAndReflection[3]);
	responseRow.put(VoteAppConstants.NOTEBOOK, reflection.replaceAll("\n", "<br>"));
    }
    if (userAndReflection.length > 4) {
	responseRow.put(VoteAppConstants.ATTR_PORTRAIT_ID, userAndReflection[4]);
    }
    rows.put(responseRow);
}
responsedata.put("rows", rows);
response.setContentType("application/json;charset=utf-8");
response.getWriter().print(new String(responsedata.toString()));
return null;
   }
 
Example 18
Project: custom-bytecode-analyzer   File: ReportItem.java   View Source Code Vote up 4 votes
public String getDecompiledFileHtml() {
  return StringEscapeUtils.escapeHtml(decompiledFile);
}
 
Example 19
Project: rapidminer   File: Tools.java   View Source Code Vote up 2 votes
/**
 * This method will encode the given string by replacing all forbidden characters by the
 * appropriate HTML entity.
 */
public static String escapeHTML(String string) {
	return StringEscapeUtils.escapeHtml(string);
}
 
Example 20
Project: DAT104   File: ValideringUtil.java   View Source Code Vote up 2 votes
/**
 * Escaper all html kode
 * 
 * @param s
 *            String som skal valideres
 * @return String uten html kode
 */
public static String escapeHTML(String s) {
	return StringEscapeUtils.escapeHtml(s);
}