我們有一個運行在glassfish服務器上的網頁。在我們的jsp文件中,我們有很多包含如下所示的內容。在jsp文件中包含大量jspf文件導致高內存使用率
<jsp:directive.include file="johndoe/foobar.jspf"/>
根據用戶選擇包含這些文件。我們的JSP文件基本上是這樣的:
<jsp:root version="2.1" xmlns:c="http://java.sun.com/jstl/core_rt"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
//some unimportant codes here
<c:if test="${sessionScope.loadAvgTest}">
//some unimportant codes here
<f:subview id="reports15">
<jsp:directive.include file="siforms/sysinfoform.jspf"/>
</f:subview>
//some unimportant codes here
<f:subview id="reports16">
<jsp:directive.include file="siforms/sysinfoformscheduled.jspf"/>
</f:subview>
//some unimportant codes here
</c:if>
//some unimportant codes here
<c:if test="${sessionScope.bandwidthTest}">
//some unimportant codes here
<f:subview id="reports17">
<jsp:directive.include file="mailforms/mailfilter.jspf"/>
</f:subview>
//some unimportant codes here
<f:subview id="reports18">
<jsp:directive.include file="mailforms/mailfilterscheduled.jspf"/>
</f:subview>
//some unimportant codes here
</c:if>
....
大約有80 if語句像這樣每一個包含2個inculdes。當我刪除了很多這些if子句,並且只有少數幾個包含內存使用情況的情況良好時。但是,如果我使用更多的if子句和更多的內存使用增長。任何想法,我可以優化代碼,或者我可以如何更改servlet配置來降低內存使用率?