Foren

Not able to use scriptlet in jsp in liferay 7

bo liu, geändert vor 6 Jahren.

Not able to use scriptlet in jsp in liferay 7

New Member Beiträge: 9 Beitrittsdatum: 20.07.17 Neueste Beiträge
Hi, I'm now working on portlet project porting from webcenter to liferay 7, and in the jsps, we are using <% include file=""/>, I can build the war file under liferay successfully, but when I deploy it, I get an error message says those scriptlets are not allowed there. Since the project works fine under webcenter, I'm wondering if there are some other configurations needs to be done in liferay 7 to enable the scriptlet in jsp? We are using tiles in the jsps, and I also manually inclue tiles-jsp.tld in the tld folder in order to deploy the war file.

This is the error message I got : ERROR render_portlet_jsp:131 -
org.apache.jasper.JasperException: search.jsp(44,80) PWC6203: Scripting elements ( &lt;%!, &lt;jsp:declaration, &lt;%=, &lt;jsp:expression, &lt;%, &lt;jsp:scriptlet ) are disallowed here.
thumbnail
Thiago Leão Moreira, geändert vor 6 Jahren.

RE: Not able to use scriptlet in jsp in liferay 7

Liferay Legend Beiträge: 1449 Beitrittsdatum: 10.10.07 Neueste Beiträge
Hi bo liu

Could you share the snippet code that generates this error?
bo liu, geändert vor 6 Jahren.

RE: Not able to use scriptlet in jsp in liferay 7

New Member Beiträge: 9 Beitrittsdatum: 20.07.17 Neueste Beiträge
Sure, I got this error in the search.jsp :we have this line <%@ include file="/WEB-INF/portlet/bits/include.jsp"%>, whenever I comment this line, the error go away.
and in include.jsp, we have:
<%@ taglib prefix="portlet" uri="http://java.sun.com/portlet" %>
<%@ taglib prefix="portlet2" uri="http://java.sun.com/portlet_2_0" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page contentType="text/html" isELIgnored="false"%>
<%@ taglib prefix="display" uri="http://displaytag.sf.net" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
thumbnail
Thiago Leão Moreira, geändert vor 6 Jahren.

RE: Not able to use scriptlet in jsp in liferay 7

Liferay Legend Beiträge: 1449 Beitrittsdatum: 10.10.07 Neueste Beiträge
Could you share the search.jsp? And make a test removing the line
&lt;%@ page contentType="text/html" isELIgnored="false"%&gt;
from include.jsp.
bo liu, geändert vor 6 Jahren.

RE: Not able to use scriptlet in jsp in liferay 7

New Member Beiträge: 9 Beitrittsdatum: 20.07.17 Neueste Beiträge
Sure, the following is our search.jsp:

<%@ include file="/WEB-INF/portlet/bits/include.jsp"%>

<portlet:defineObjects/>
<script>
function reloadSouthern() {
$('#southern').find('option:first').attr('selected', 'selected');
}
function reloadNorthern() {
$('#northern').find('option:first').attr('selected', 'selected');
}
</script>


<tiles:insertDefinition name="defaultTemplate">
<tiles:putAttribute name="body">
<portlet:actionURL var="formAction">
<portlet:param name="bitsAction" value="searchAction"/>
</portlet:actionURL>
<portlet:actionURL var="formAdvancedSearchAction">
<portlet:param name="bitsAction" value="searchAction"/>
</portlet:actionURL>

<div class="body">
<div class="main">
<div class="main-body-pages">
<form:form method="post" id="searchForm"
commandName="searchInfo" action="${formAction}">
<div class="BITScontainer">
<br></br>
<div class="row well">
<div class="col-md-12">
<h2>Search</h2>
<div id="custom-search-input">
<div class="input-group col-md-12">
<form:input type="text"
class="form-control input-lg"
path="searchData"
autocomplete="off"
onkeydown="if (event.keyCode == 13) document.getElementById('search').click()"/>

<span class="input-group-btn">
<input type="submit"
value="search"
id="search"
style="background:url(<%=bits.utils.BITSPropertiesUtil.getPropertyValue(bits.utils.BITSConstants.BITS_RESOURCES_URL )%>images) no-repeat;width:25px;height:25px;"/>
</span>
</div>
</div>
</div>
</div>
<form:form method="post" id="searchForm"
commandName="searchInfo" action="${formAdvancedSearchAction}">
<div class="row well" id="advSearch">
<div class="col-xs-4 col-sm-4">
<label class="labels">Northern</label>

<form:select class="form-control" path="northern" id="northern" onchange="javascript:reloadSouthern()">
<form:options items="${northBorderLOV}"
itemValue="lovDescr"
itemLabel="lovDescr"/>
</form:select>
</div>
<div class="col-xs-4 col-sm-4">
<label class="labels">Southern</label>

<form:select class="form-control" path="southern" id="southern" onchange="javascript:reloadNorthern()">
<form:options items="${southLOV}"
itemValue="lovDescr"
itemLabel="lovDescr"/>

</form:select>
</div>
<br>
<br>
<br>
<br>
<div class="pull-right">
<input type="submit" id="search"
class="btn btn-primary"
value="Browse"/>
</div>
</div>
</form:form>
<div class="row" id="SearchResults">
<c:if test="${not empty searchList}">
<h3>Search Results</h3>

<display:table name="searchList" id="table" pagesize="15" sort="list" class="displaytag" >
<display:column title="Abbreviated Name" sortable="true" headerClass="sortable" sortProperty="abbreviation" >
<a style="font-family: Tahoma, Verdana, Helvetica, sans-serif;font-size: 11px;"
href="<portlet:actionURL><portlet:param name="bitsAction" value="selectCrossing" />
<portlet:param name="crossingId" value="${table.crossingId}" />
</portlet:actionURL>"><b>${table.abbreviation}</b>
</a>
</display:column>
<display:column property="officialName" sortable="true" headerClass="sortable" />
<display:column property="cbp" sortable="true" headerClass="sortable"/>
<display:column property="cb" sortable="true" headerClass="sortable"/>
<display:column property="Code" sortable="true" headerClass="sortable"/>
<display:column property="b" sortable="true" headerClass="sortable" />
<display:column property="t" sortable="true" headerClass="sortable" />
<display:column property="s" sortable="true" headerClass="sortable" />
</display:table>
</c:if>

<c:if test="${searchList != null}">
<c:if test="${empty searchList}">
<h3>Search Results</h3>
<p style="font-family:'Times New Roman', 'Arial Black', times, Serif; font-size:16px;">No
Search
Results
Found.
Please
Modify
Your
Search
Criteria.</p>
</c:if>
</c:if>

<br></br><br></br>

<br></br>
</div>
<br></br>

<br></br>
</div>
</form:form>
</div>
</div>
</div>
<script>
$('#searchForm').submit(function (e) {
e.preventDefault();
$('#searchResults').show();
});
</script>
</tiles:putAttribute>
</tiles:insertDefinition>