Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.sction.mvc.viewrender;
 
 import java.util.Date;
 
 
public class DefaultJSONViewRender implements ViewRender {
	public void render(ServletContext servletContext,
			Object objString encodingController controllerAction action)
			throws Exception {
		response.reset();
		response.setContentType("application/json; charset=" + encoding);
		response.setHeader("Cache-Control""no-cache");
		response.setCharacterEncoding(encoding);
		PrintWriter out2 = response.getWriter();
		if (obj instanceof String) {
			out2.print(obj);
			out2.flush();
			out2.close();
			return;
		}
		JsonConfig jsonConfig = new JsonConfig();
		JSON json = JSONUtils.toJSON(objjsonConfig);
		String callback = request.getParameter("callback");
		if (callback != null && !callback.trim().equals("")
				&& callback.equals("=?")) {
			callback = callback.substring(0, callback.length() - 2) + "("
json.toString() + ");";
			out2.print(callback);
else {
			out2.print(json);
		}
		out2.flush();
		out2.close();
	}
New to GrepCode? Check out our FAQ X