Scripting elements (

发布时间:2025-02-04 06:40

最新推荐文章于 2023-08-31 15:53:29 发布

tomjourney 于 2018-02-09 00:41:50 发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

<%@ page contentType="text/html;charset=UTF-8" %>

<%

session.setAttribute("pageContext", "it315");

%>

输出表达式\\${pageContext}的值:<br/>

${pageContext}

【web.xml】错误地在 web.xml中禁用了 jsp脚本元素

<jsp-config>

<jsp-property-group>

<url-pattern>*.jsp</url-pattern>

<page-encoding>UTF-8</page-encoding>

</jsp-property-group>

<jsp-property-group>

<url-pattern>*.jsp</url-pattern>

<el-ignored>true</el-ignored>

</jsp-property-group>

<jsp-property-group>

<url-pattern>*.jsp</url-pattern>

<scripting-invalid>true</scripting-invalid>

</jsp-property-group>

</jsp-config>

【报错信息如下】


【解决方法】 在web.xml中 把 禁用 jsp 脚本元素的配置信息删除即可;

【访问效果如下】

【web.xml 源码】

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">

<servlet>

<servlet-name>default</servlet-name>

<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>

<init-param>

<param-name>debug</param-name>

<param-value>0</param-value>

</init-param>

<init-param>

<param-name>listings</param-name>

<param-value>false</param-value>

</init-param>

<load-on-startup>1</load-on-startup>

</servlet>

<servlet-mapping>

<servlet-name>default</servlet-name>

<url-pattern>/</url-pattern>

</servlet-mapping>

<servlet>

<servlet-name>jsp</servlet-name>

<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>

<init-param>

<param-name>fork</param-name>

<param-value>false</param-value>

</init-param>

<init-param>

<param-name>xpoweredBy</param-name>

<param-value>false</param-value>

</init-param>

<load-on-startup>3</load-on-startup>

</servlet>

<servlet-mapping>

<servlet-name>jsp</servlet-name>

<url-pattern>*.jsp</url-pattern>

<url-pattern>*.jspx</url-pattern>

</servlet-mapping>

<mime-mapping>

<extension>abs</extension>

<mime-type>audio/x-mpeg</mime-type>

</mime-mapping>

<jsp-config>

<jsp-property-group>

<url-pattern>*.jsp</url-pattern>

<page-encoding>UTF-8</page-encoding>

</jsp-property-group>

</jsp-config>

<session-config>

<session-timeout>1</session-timeout>

</session-config>

</web-app>

【implicitObj.jsp】

<%@ page contentType="text/html;charset=UTF-8" %>

<%

session.setAttribute("pageContext", "it315");

%>

输出表达式\${pageContext}的值:<br/>

${pageContext}

【implicitObj_jsp.java】

/*

* Generated by the Jasper component of Apache Tomcat

* Version: Apache Tomcat/7.0.35

* Generated at: 2018-02-08 16:45:35 UTC

* Note: The last modified time of this file was set to

* the last modified time of the source file after

* generation to assist with modification tracking.

*/

package org.apache.jsp.chapter5.ex5_005f4;

import javax.servlet.*;

import javax.servlet.http.*;

import javax.servlet.jsp.*;

public final class implicitObj_jsp extends org.apache.jasper.runtime.HttpJspBase

implements org.apache.jasper.runtime.JspSourceDependent {

private static final javax.servlet.jsp.JspFactory _jspxFactory =

javax.servlet.jsp.JspFactory.getDefaultFactory();

private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;

private javax.el.ExpressionFactory _el_expressionfactory;

private org.apache.tomcat.InstanceManager _jsp_instancemanager;

public java.util.Map<java.lang.String,java.lang.Long> getDependants() {

return _jspx_dependants;

}

public void _jspInit() {

_el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();

_jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());

}

public void _jspDestroy() {

}

public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)

throws java.io.IOException, javax.servlet.ServletException {

final javax.servlet.jsp.PageContext pageContext;

javax.servlet.http.HttpSession session = null;

final javax.servlet.ServletContext application;

final javax.servlet.ServletConfig config;

javax.servlet.jsp.JspWriter out = null;

final java.lang.Object page = this;

javax.servlet.jsp.JspWriter _jspx_out = null;

javax.servlet.jsp.PageContext _jspx_page_context = null;

try {

response.setContentType("text/html;charset=UTF-8");

pageContext = _jspxFactory.getPageContext(this, request, response,

null, true, 8192, true);

_jspx_page_context = pageContext;

application = pageContext.getServletContext();

config = pageContext.getServletConfig();

session = pageContext.getSession();

out = pageContext.getOut();

_jspx_out = out;

out.write('\r');

out.write('\n');

session.setAttribute("pageContext", "it315");

out.write("\r\n");

out.write("输出表达式${pageContext}的值:<br/>\r\n");

out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false));

out.write(' ');

} catch (java.lang.Throwable t) {

if (!(t instanceof javax.servlet.jsp.SkipPageException)){

out = _jspx_out;

if (out != null && out.getBufferSize() != 0)

try { out.clearBuffer(); } catch (java.io.IOException e) {}

if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);

else throw new ServletException(t);

}

} finally {

_jspxFactory.releasePageContext(_jspx_page_context);

}

}

}

网址:Scripting elements ( https://www.yuejiaxmz.com/news/view/754498

相关内容

307个高质量真实电影感自然城市生活氛围车辆场景音效素材包 Cinematic Elements
探索Bash脚本的魅力:自动化你的日常任务
JSP脚本元素(声明 %! 表达式 %= 脚本 %)
LSL脚本性能优化秘籍:代码剖析与效率提升策略
'c' argument has 22 elements, which is
el
深度学习目标检测常用工具型代码:对训练数据的trainval.txt进行数据清洗
《生活禅钥》 || 物质生活要简朴,精神生活要高尚
[DOM] Input elements should have autocomplete attributes (suggested: 'current
环境计测质量控制.docx

随便看看