All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nutz.plugins.view.JspView Maven / Gradle / Ivy

package org.nutz.plugins.view;

import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.nutz.lang.Lang;

public class JspView extends AbstractTemplateViewResolver {

	@Override
	public void render(HttpServletRequest req, HttpServletResponse resp,
			String evalPath, Map sharedVars) throws Throwable {
		Iterator> iter = sharedVars.entrySet().iterator();
		while (iter.hasNext()) {
			Map.Entry entry = iter.next();
			String key = entry.getKey().toString();
			Object val = entry.getValue();
			req.setAttribute(key, val);
		}
		RequestDispatcher rd = req.getRequestDispatcher(evalPath);
        if (rd == null)
            throw Lang.makeThrow("Fail to find Forward '%s'", evalPath);
        // Do rendering
        rd.forward(req, resp);
	}

	@Override
	protected void init(String appRoot, ServletContext sc) {
		
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy