eclipse-ee4j / glassfish

Eclipse GlassFish
https://eclipse-ee4j.github.io/glassfish/
380 stars 144 forks source link

ignoreJspFragmentErrors does not work #22757

Closed caim2015 closed 4 years ago

caim2015 commented 5 years ago

Environment Details

Problem Description

My test sample is very simple. Only two JSPs. 1.moto.jsp

<%@ page contentType="text/html; charset=utf-8" %>
<%@ page pageEncoding="utf-8" %>
<%
    String s_sheet = "../../StyleSheet/style.css";
    String str = "aaa";
%>



 moto.jsp
 


 <%@ include file="./b/button.jsp"%>


2.button.jsp

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



<% if ("aaa".equals(str)){ %>
  
<% } %>

When I deploy my sample,[Precompile JSPs]is selected from Web Console, I get this error:

PWC6197: An error occurred at line: 6 in the jsp file: /page/b/button.jsp
PWC6199: Generated servlet error:
cannot find symbol
  symbol:  variable  str
  location: class org.apache.jsp.page.b.button_jsp

In order to ignore this error, I set "ignoreJspFragmentErrors" to true. but it does not work.

sample_NO.zip

caim2015 commented 5 years ago

When I change 'relative' path to 'absolute' path like the following,it becomes work. The precompilation error is successfully ignored.

<%@ include file="./b/button.jsp"%>
↓
<%@ include file="/page/b/button.jsp"%>

As we all know,in the JSP Include directive using 'relative' and 'absolute' path both are valid. So,I think this is a bug .

nitind commented 5 years ago

The JSP specification recommends the .jsp extension be used only for files corresponding to top level JSP files, forming a complete JSP page when processed. What happens if you use .jspf for the fragment file name and change nothing else?

caim2015 commented 5 years ago

The JSP specification recommends the .jsp extension be used only for files corresponding to top level JSP files, forming a complete JSP page when processed. What happens if you use .jspf for the fragment file name and change nothing else?

If .jsp is changed to .jspf, the error do not happen. Because even if [Precompile JSPs] is selected, the "button.jspf" is not be precompiled. Only the .jsp , .jspx files are precompile targets.

button.jsp
↓
button.jspf

<%@ include file="./b/button.jsp"%>
↓
<%@ include file="./b/button.jspf"%>
github-actions[bot] commented 4 years ago

This issue has been marked as inactive and old and will be closed in 7 days if there is no further activity. If you want the issue to remain open please add a comment