Question:
I’ve been told that you cannot have dynamic virtual includes inJSP. Is this true? For example, is something like this going tocause problems?
<% if (condition.equals("true")) { %><% } else { %><% } %>
Answer:
JSP is still relatively new, so I won’t claim to know all of its insand outs, but it looks to me like you’re mixing Server Side Includes(SSI) syntax with JSP code. It is indeed possible to perform dynamicJSP includes, but you must use the
<%! java.util.Random random = new java.util.Random(System.currentTimeMillis()); %><% if (random.nextInt() % 2 != 0) { %> <% } else { %> <% } %>
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.























