Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.viaoa.web.util;
import java.awt.Window;
import java.util.Enumeration;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.viaoa.hub.Hub;
import com.viaoa.object.OAObject;
import com.viaoa.template.OATemplate;
import com.viaoa.util.OAStr;
import com.viaoa.util.OAString;
import com.viaoa.web.html.OAHtmlComponent;
import com.viaoa.web.server.OASession;
/**
* Utility used to convert dynamic data for internal text, so that it is html and javascript safe.
*
* Data that is sent as code to the browser needs to be converted, so that the code that is created for
* it does not break, either within the javascript or html.
*
* The outer js code will wrap the text in single or double quotes, and can then have html inside of it.
* The html can also have js code in it, so there is various encoding/escaping that needs to be done to
* have well formed js and html that will not break the back from processing it.
*
*
* @author vvia
*/
public class OAWebUtil {
public static void debug(ServletContext application, OASession oasession, HttpServletRequest request, HttpServletResponse response) {
System.out.print("realPath=" + application.getRealPath("test"));
System.out.print(", servletPath=" + request.getServletPath());
System.out.print(", pathInfo=" + request.getPathInfo());
System.out.println(", pathTranslated=" + request.getPathTranslated());
System.out.print("requestURI=" + request.getRequestURI());
System.out.print(", serverName=" + request.getServerName());
System.out.println(" serverPort=" + request.getServerPort());
Enumeration enumx = request.getParameterNames();
while (enumx.hasMoreElements()) {
String name = (String) enumx.nextElement();
String[] values = request.getParameterValues(name);
if (values.length == 0) System.out.println("param: name=" + name + " values=null");
else if (values.length == 1) System.out.println("param: name=" + name + " value=" + values[0]);
else {
for (int i = 0; i < values.length; i++) {
System.out.println("param: name=" + name + " value[" + i + "]=" + values[i]);
}
}
}
}
/**
* Helper method use to make sure that text is correctly escaped to be inside of javascript code.
* This will call createJsString(text, '"', false, false)
*/
/* public static String createText(final String text) { String s = createJsString(text, '"', false,
* true); return s; } public static String createText(final String text, char quoteChar) { String s
* = createJsString(text, quoteChar, false, true); return s; }
*
*
* public static String createHtml(final String text) { String s = createJsString(text, '"', false,
* true); return s; } public static String createHtml(final String text, char quoteChar) { String s
* = createJsString(text, quoteChar, false, true); return s; } */
/* This is only needed when putting html code/data inside of something that is quoted.
*
* where data = "John's" and would need to be convertedto "John's" example:
*
* @return */
public static String createEmbeddedHtmlString(final String text, final char htmlQuoteChar) {
String s;
if (htmlQuoteChar == '\'') s = OAString.convert(text, "\'", "'"); // ' not yet supported
else if (htmlQuoteChar == '\"') s = OAString.convert(text, "\"", """); // "
else s = text;
return s;
}
/* Javascript code that is inside of JS > Html example:
* $('#id').html(" ..