I'd like to pass the HTML page title to an included jsp page but the title is passed to the view in a request attribute that happens to be a hashMap dbTable
This works but I don't like that I have Java mixed in with my view
<%@ page import="java.util.HashMap" %>
<% HashMap dbTable = ((HashMap)request.getAttribute("dbTable")); %>
<jsp:include page="inc_header.jsp" flush="true">
<jsp:param name="pageTitle" value="<%= \"Confirm Delete \" + ((HashMap)request.getAttribute(\"dbTable\")).get(\"strTableTitle\") + \" Data \"%>" />
</jsp:include>
I am only using jsp 1.2 so this doesn't work (title just shows EL statement)
<jsp:include page="inc_header.jsp" flush="true">
<jsp:param name="pageTitle" value="Confirm Deletion of ${dbTable.strTableTitle} data" />
</jsp:include>
This works in the page body
<h1>Confirm Deletion of <c:out value="${dbTable.strTableTitle}" /> Data </h1>
but this gives unterminated string error
<jsp:include page="inc_header.jsp" flush="true">
<jsp:param name="pageTitle" value="Confirm Deletion of <c:out value="${dbTable.strTableTitle}" /> data" />
</jsp:include>
Any thought on how to do this cleaner? The header is used by all my views and开发者_开发百科 I would like to build the final Title String (e.g., Confirm Delete
HashMap.DatabaseTitle data
) in each view template.
You've to upgrade to at least JSP 2.0 to get EL in <jsp:param>
to work. JSP 1.2 syntax reference doesn't mention of any EL support in <jsp:param>
, while JSP 2.0 syntax reference does.
精彩评论