简体   繁体   中英

jsp print variable inside of <jsp:attribute>

How can I print a HTTP Request parameter inside of a <jsp:body> ?

The following doesn't work.

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="t" tagdir="/WEB-INF/tags" %>
<t:basePage>
   <jsp:attribute name="title">Reset Password</jsp:attribute>
   <jsp:attribute name="lib">lib/</jsp:attribute>
   <jsp:attribute name="bodyClass">loginPage</jsp:attribute>
   <jsp:body>
      <%= request.getParameter("msg"); %>
   </jsp:body>
</t:basePage>

I get this error: HTTP Status 500 - /message.jsp (line: 39, column: 22) Scripting elements ( &lt;%!, &lt;jsp:declaration, &lt;%=, &lt;jsp:expression, &lt;%, &lt;jsp:scriptlet ) are disallowed here.

Try with Expression Language

${requestScope.param.msg} 

OR simply

 ${msg} 

may be your configuration disables scripting elements.

EDIT

This does not relate to your current requirement since scripting elements seem to be disabled at your end. However the below is syntactically incorrect

<%= request.getParameter("msg"); %>

You must never add a ; after expression_here <%= #expression_here %>

for the simple reason that it translates to out.print(msg;); which is syntactically incorrect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM