Essential ATG Dynamo Training - Got atg Certified Relationship Management Developer?
This is not an official ATG site: ATG, Dynamo, Scenario Server and Personalization Server are trademarks or registered trademarks of Art Technology Group
Articles Exercises Resources Links Search

What's the Deal with java tags in JSP and JHTML Pages?

Note: The information in this article is for Dynamo 5.1 only

Example Code

Let's look at an example. The server code below uses both <java> and <% %> tags, we can save the same page with both a .jsp and .jhtml extension and get different results

<HTML> <HEAD>
<TITLE>Java Server Page</TITLE>
</HEAD>

<BODY BGCOLOR="#FFFFFF">
<H1>Java Server Page</H1>

<% 
   int iJavaTag=0;
   int iJSPTag=0; 
%>
  
<java>
  iJavaTag++;
</java>

<% 
  iJSPTag++;
%>

<% out.println("<br>Test JSP <java> tag: " + iJavaTag); %>
<% out.println("<br>Test JSP < %  % > tag: " + iJSPTag); %>

</BODY> </HTML>

As a JHTML Page

You can effectively use the jsp tags <% and %> in a JHTML page for java code, the result of firing up our java_server_page.jhtml page is as follows:

<H1>Java Server Page</H1>
<BR>Test JSP <JAVA>tag: 1 
<BR>Test JSP < % % > tag: 1 

We see that both the <% %> and <java> tag delimited code is part of the page servlet

As a JSP Page

You cannot effectively use the jhtml tags <java> in a JSP page for java code, the result of firing up our java_server_page.jsp page is as follows:

<H1>Java Server Page</H1>
<JAVA>iJavaTag++; </JAVA>
<BR>Test JSP <JAVA>tag: 0 
<BR>Test JSP < % % > tag: 1 

We see that the <java> tags are not processed on the server and are passed down untouched to the client. This is because these tags are not a part of the JSP specification.

Summary

Files ending in .JHTML are processed with the JHTML tags enabled as a superset of the JSP standard.

This means:

  • You can save JSP pages as .jhtml files and they will work fine
  • JHTML tags are not processed on the server for .jsp files
 


Technical Training Advertise your Training Programs for Free! Los Angeles Web Design Shopping Cart Software  Form a Corporation