本文整理汇总了Java中org.apache.jasper.EmbeddedServletOptions类的典型用法代码示例。如果您正苦于以下问题:Java EmbeddedServletOptions类的具体用法?Java EmbeddedServletOptions怎么用?Java EmbeddedServletOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EmbeddedServletOptions类属于org.apache.jasper包,在下文中一共展示了EmbeddedServletOptions类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getServletFileNameForJsp
import org.apache.jasper.EmbeddedServletOptions; //导入依赖的package包/类
@Override
public String getServletFileNameForJsp(Context context, String jspName) {
String servletName = null;
ServletConfig servletConfig = (ServletConfig) context.findChild("jsp");
if (servletConfig != null) {
ServletContext sctx = context.getServletContext();
Options opt = new EmbeddedServletOptions(servletConfig, sctx);
JspRuntimeContext jrctx = new JspRuntimeContext(sctx, opt);
JspCompilationContext jcctx = createJspCompilationContext(jspName, opt, sctx, jrctx, null);
servletName = jcctx.getServletJavaFileName();
} else {
logger.error(NO_JSP_SERVLET, context.getName());
}
return servletName;
}
示例2: handleContext
import org.apache.jasper.EmbeddedServletOptions; //导入依赖的package包/类
@Override
protected ModelAndView handleContext(String contextName, Context context,
HttpServletRequest request, HttpServletResponse response) throws Exception {
String jspName = ServletRequestUtils.getStringParameter(request, "source", null);
ServletContext sctx = context.getServletContext();
ServletConfig scfg = (ServletConfig) context.findChild("jsp");
Options opt = new EmbeddedServletOptions(scfg, sctx);
String encoding = opt.getJavaEncoding();
String content = null;
if (jspName != null) {
String servletName =
getContainerWrapper().getTomcatContainer().getServletFileNameForJsp(context, jspName);
if (servletName != null) {
File servletFile = new File(servletName);
if (servletFile.exists()) {
try (FileInputStream fis = new FileInputStream(servletFile)) {
content = Utils.highlightStream(jspName, fis, "java", encoding);
}
}
}
}
return new ModelAndView(getViewName(), "content", content);
}
示例3: handleContext
import org.apache.jasper.EmbeddedServletOptions; //导入依赖的package包/类
protected ModelAndView handleContext(String contextName, Context context,
HttpServletRequest request, HttpServletResponse response) throws Exception {
String jspName = ServletRequestUtils.getStringParameter(request, "source", null);
ServletContext sctx = context.getServletContext();
ServletConfig scfg = (ServletConfig) context.findChild("jsp");
Options opt = new EmbeddedServletOptions(scfg, sctx);
String encoding = opt.getJavaEncoding();
String content = null;
if (jspName != null) {
String servletName = getContainerWrapper().getTomcatContainer().getServletFileNameForJsp(context, jspName);
if (servletName != null) {
File servletFile = new File(servletName);
if (servletFile.exists()) {
FileInputStream fis = new FileInputStream(servletFile);
try {
content = Utils.highlightStream(jspName, fis, "java", encoding);
} finally {
fis.close();
}
}
}
}
return new ModelAndView(getViewName(), "content", content);
}
示例4: rewriteJasperSystemClasspath
import org.apache.jasper.EmbeddedServletOptions; //导入依赖的package包/类
private void rewriteJasperSystemClasspath(WebAppContext context) throws NoSuchFieldException, IllegalAccessException {
JettyJspServlet jspServlet = (JettyJspServlet) context.getServletHandler().getServlet("jsp").getServletInstance();
// the options field is in JettyJspServlet's parent, JspServlet
Class<?> JspServletClass = jspServlet.getClass().getSuperclass();
Field optionsField = JspServletClass.getDeclaredField("options");
optionsField.setAccessible(true);
EmbeddedServletOptions options = (EmbeddedServletOptions) optionsField.get(jspServlet);
String sysClassPath = options.getProperty("com.sun.appserv.jsp.classpath");
String filteredSysClassPath = filterSysClassPath(sysClassPath);
options.setProperty("com.sun.appserv.jsp.classpath", filteredSysClassPath);
}
示例5: getServletFileNameForJsp
import org.apache.jasper.EmbeddedServletOptions; //导入依赖的package包/类
public String getServletFileNameForJsp(Context context, String jspName) {
String servletName = null;
ServletConfig servletConfig = (ServletConfig) context.findChild("jsp");
if (servletConfig != null) {
ServletContext sctx = context.getServletContext();
Options opt = new EmbeddedServletOptions(servletConfig, sctx);
JspRuntimeContext jrctx = new JspRuntimeContext(sctx, opt);
JspCompilationContext jcctx = createJspCompilationContext(jspName, false, opt, sctx, jrctx, null);
servletName = jcctx.getServletJavaFileName();
} else {
logger.error("Context " + context.getName() + " does not have \"jsp\" servlet");
}
return servletName;
}
示例6: init
import org.apache.jasper.EmbeddedServletOptions; //导入依赖的package包/类
public void init(ServletConfig config) throws ServletException {
super.init(config);
this.config = config;
this.context = config.getServletContext();
// Initialize the JSP Runtime Context
options = new EmbeddedServletOptions(config, context);
rctxt = new JspRuntimeContext(context,options);
// START SJSWS 6232180
// Determine which HTTP methods to service ("*" means all)
httpMethodsString = config.getInitParameter("httpMethods");
if (httpMethodsString != null
&& !httpMethodsString.equals("*")) {
httpMethodsSet = new HashSet<String>();
StringTokenizer tokenizer = new StringTokenizer(
httpMethodsString, ", \t\n\r\f");
while (tokenizer.hasMoreTokens()) {
httpMethodsSet.add(tokenizer.nextToken());
}
}
// END SJSWS 6232180
// START GlassFish 750
taglibs = new ConcurrentHashMap<String, TagLibraryInfo>();
context.setAttribute(Constants.JSP_TAGLIBRARY_CACHE, taglibs);
tagFileJarUrls = new ConcurrentHashMap<String, URL>();
context.setAttribute(Constants.JSP_TAGFILE_JAR_URLS_CACHE,
tagFileJarUrls);
// END GlassFish 750
if (log.isLoggable(Level.FINEST)) {
log.finest(Localizer.getMessage("jsp.message.scratch.dir.is",
options.getScratchDir().toString()));
log.finest(Localizer.getMessage("jsp.message.dont.modify.servlets"));
}
this.jspProbeEmitter = (JspProbeEmitter)
config.getServletContext().getAttribute(
"org.glassfish.jsp.monitor.probeEmitter");
}
示例7: handleContext
import org.apache.jasper.EmbeddedServletOptions; //导入依赖的package包/类
@Override
protected ModelAndView handleContext(String contextName, Context context,
HttpServletRequest request, HttpServletResponse response) throws Exception {
String jspName = ServletRequestUtils.getStringParameter(request, "source", null);
boolean highlight = ServletRequestUtils.getBooleanParameter(request, "highlight", true);
Summary summary = (Summary) (request.getSession(false) != null
? request.getSession(false).getAttribute(DisplayJspController.SUMMARY_ATTRIBUTE) : null);
if (jspName != null && summary != null && contextName.equals(summary.getName())) {
Item item = summary.getItems().get(jspName);
if (item != null) {
// replace "\" with "/"
jspName = jspName.replaceAll("\\\\", "/");
// remove cheeky "../" from the path to avoid exploits
while (jspName.contains("../")) {
jspName = jspName.replaceAll("\\.\\./", "");
}
if (getContainerWrapper().getTomcatContainer().resourceExists(jspName, context)) {
ServletContext sctx = context.getServletContext();
ServletConfig scfg = (ServletConfig) context.findChild("jsp");
Options opt = new EmbeddedServletOptions(scfg, sctx);
String descriptorPageEncoding =
opt.getJspConfig().findJspProperty(jspName).getPageEncoding();
if (descriptorPageEncoding != null && descriptorPageEncoding.length() > 0) {
item.setEncoding(descriptorPageEncoding);
} else {
/*
* we have to read the JSP twice, once to figure out the content encoding the second
* time to read the actual content using the correct encoding
*/
try (InputStream encodedStream =
getContainerWrapper().getTomcatContainer().getResourceStream(jspName, context)) {
item.setEncoding(Utils.getJspEncoding(encodedStream));
}
}
try (InputStream jspStream =
getContainerWrapper().getTomcatContainer().getResourceStream(jspName, context)) {
if (highlight) {
request.setAttribute("highlightedContent",
Utils.highlightStream(jspName, jspStream, "xhtml", item.getEncoding()));
} else {
request.setAttribute("content", Utils.readStream(jspStream, item.getEncoding()));
}
}
} else {
logger.error("{} does not exist", jspName);
}
request.setAttribute("item", item);
} else {
logger.error("jsp name passed is not in the summary, ignored");
}
} else {
if (jspName == null) {
logger.error("Passed empty 'source' parameter");
}
if (summary == null) {
logger.error("Session has expired or there is no summary");
}
}
return new ModelAndView(getViewName());
}
示例8: recompileJsps
import org.apache.jasper.EmbeddedServletOptions; //导入依赖的package包/类
/**
* Compiles a list of JSPs. Names of JSP files are expected to be relative to the webapp root. The method
* updates summary with compilation details.
*
* @param context
* @param summary
* @param names
*/
public void recompileJsps(Context context, Summary summary, List names) {
ServletConfig servletConfig = (ServletConfig) context.findChild("jsp");
if (servletConfig != null) {
if (summary != null) {
synchronized (servletConfig) {
ServletContext sctx = context.getServletContext();
Options opt = new EmbeddedServletOptions(servletConfig, sctx);
JspRuntimeContext jrctx = new JspRuntimeContext(sctx, opt);
try {
//
// we need to pass context classloader here, so the jsps can reference /WEB-INF/classes and
// /WEB-INF/lib. JspCompilationContext would only take URLClassLoader, so we fake it
//
URLClassLoader classLoader = new URLClassLoader(new URL[]{}, context.getLoader().getClassLoader());
for (Iterator it = names.iterator(); it.hasNext();) {
String name = (String) it.next();
long time = System.currentTimeMillis();
JspCompilationContext jcctx = createJspCompilationContext(name, false, opt, sctx, jrctx, classLoader);
ClassLoader prevCl = ClassUtils.overrideThreadContextClassLoader(classLoader);
try {
Item item = (Item) summary.getItems().get(name);
if (item != null) {
try {
org.apache.jasper.compiler.Compiler c = jcctx.createCompiler();
c.compile();
item.setState(Item.STATE_READY);
item.setException(null);
logger.info("Compiled " + name + ": OK");
} catch (Exception e) {
item.setState(Item.STATE_FAILED);
item.setException(e);
logger.info("Compiled " + name + ": FAILED", e);
}
item.setCompileTime(System.currentTimeMillis() - time);
} else {
logger.error(name + " is not on the summary list, ignored");
}
} finally {
ClassUtils.overrideThreadContextClassLoader(prevCl);
}
}
} finally {
jrctx.destroy();
}
}
} else {
logger.error("summary is null for " + context.getName() + ", request ignored");
}
} else {
logger.error("Context " + context.getName() + " does not have \"jsp\" servlet");
}
}
示例9: handleContext
import org.apache.jasper.EmbeddedServletOptions; //导入依赖的package包/类
protected ModelAndView handleContext(String contextName, Context context,
HttpServletRequest request, HttpServletResponse response) throws Exception {
String jspName = ServletRequestUtils.getStringParameter(request, "source", null);
boolean highlight = ServletRequestUtils.getBooleanParameter(request, "highlight", true);
Summary summary = (Summary) (request.getSession() != null ?
request.getSession().getAttribute(DisplayJspController.SUMMARY_ATTRIBUTE) : null);
if (jspName != null && summary != null && contextName.equals(summary.getName())) {
Item item = (Item) summary.getItems().get(jspName);
if (item != null) {
//
// replace "\" with "/"
//
jspName = jspName.replaceAll("\\\\", "/");
//
// remove cheeky "../" from the path to avoid exploits
//
while (jspName.indexOf("../") != -1) {
jspName = jspName.replaceAll("\\.\\./", "");
}
Resource jsp = (Resource) context.getResources().lookup(jspName);
if (jsp != null) {
ServletContext sctx = context.getServletContext();
ServletConfig scfg = (ServletConfig) context.findChild("jsp");
Options opt = new EmbeddedServletOptions(scfg, sctx);
String descriptorPageEncoding = opt.getJspConfig().findJspProperty(jspName).getPageEncoding();
if (descriptorPageEncoding != null && descriptorPageEncoding.length() > 0) {
item.setEncoding(descriptorPageEncoding);
} else {
//
// we have to read the JSP twice, once to figure out the content encoding
// the second time to read the actual content using the correct encoding
//
item.setEncoding(Utils.getJSPEncoding(jsp.streamContent()));
}
if (highlight) {
request.setAttribute("highlightedContent", Utils.highlightStream(jspName, jsp.streamContent(),
"xhtml", item.getEncoding()));
} else {
request.setAttribute("content", Utils.readStream(jsp.streamContent(), item.getEncoding()));
}
} else {
logger.error(jspName + " does not exist");
}
request.setAttribute("item", item);
} else {
logger.error("jsp name passed is not in the summary, ignored");
}
} else {
if (jspName == null) {
logger.error("Passed empty \"source\" parameter");
}
if (summary == null) {
logger.error("Session has expired or there is no summary");
}
}
return new ModelAndView(getViewName());
}
示例10: setConfig
import org.apache.jasper.EmbeddedServletOptions; //导入依赖的package包/类
public void setConfig(ServletConfig config) {
this.config = config;
context = config.getServletContext();
options = new EmbeddedServletOptions(config, context);
runtimeContext = new JspRuntimeContext(context, options);
}