2

I have faced a very strange issue with jsp:include tag in WebLogic12c and have no clue how to find the root cause or fix it. Please help!!!

I am using on my project Struts 2.5.10.1 and Tiles 3.0.7. The JSP page is very simple. It basically uses tiles template and provides content for central frame using another JSP page which is dynamically included like this:

...
   <tiles:insertDefinition name="defaultLayout">
   <tiles:putAttribute name="content">

        <div id="fragment-connection" class="aetab-content"> 
               <jsp:include page="idas_tab_connect.jsp" />
            </div> 

   </tiles:putAttribute>
</tiles:insertDefinition>  
...

The issue is that instead of entire content of the idas_tab_connect.jsp page only text is included. All HTML markup is simply gone. Even instead of input text field I see on the resulted page just values.

The same code works fine on JBoss 6.4 and Tomcat 7 and 8. So it seems this is some WebLogic-specific issue.

Thank you for your help in advance.

Additional details:

  • JDK - 1.7;
  • Servlet version - 2.4;
  • OS - Windows 10, x64;
  • The generated HTML looks like this:

    <div id="fragment-connection" class="aetab-content"> Connection SettingsLDAP Connection SettingsHost:Port:389Use SSL:Trusted keystore file location on server:User DN:Password:Confirm Password: </div>

Root cause

As I mentioned below in my comment I found the root cause - page encoding/charset set in the included page as "UTF-8"

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

If I change charset/pageEncoding to "utf-8", "utf8" or something completely wrong, for instance "xxxx" or remove it everything starts working fine for me.

Very strange issue. At least now I have a workaround.

user2525437
  • 155
  • 4
  • If I use <%@ include file="idas_tab_connect.jsp" %> instead everything works fine. But unfortunately I cannot use static include due to some specific reasons. – user2525437 Jun 27 '17 at 11:35
  • Another strange thing. On some JSP pages code like this request.isUserInRole("admin") works fine while on other fails. After some investigation I found that this issue happens when WebLogic moves part of the JSP page to a helper class JspFragmentHelper. In that case it makes the request object available as ServletRequest which of course causes class cast exceptions and fails JSP compilation. The only solution that I found is to add explicit cast to HttpServletRequest to resolve this issue. And again in Tomcat and JBoss everything works fine. – user2525437 Jun 27 '17 at 11:45
  • Is this only in this page or no jsp:include works anywhere within your application? – ramp Jun 29 '17 at 07:27
  • This issue is reproducible on all pages. – user2525437 Jun 29 '17 at 08:24
  • I have just found the root cause of this problem - for some reason it happens only if the included page has charset or pageEncoding set to "UTF-8". If I change charser/pageEncoding to "utf-8", "utf8" or something completely wrong like "xxxx" the issue is gone and I am able to see correctly included page with all HTML markup. Still not clear why this happens but at least I have a workaround. – user2525437 Jun 29 '17 at 08:26

0 Answers0