Helping ordinary people create extraordinary websites!

JSP Technology -- Friend or Foe?

By Brett McLaughlin
2003-03-07

Content vs. presentation
Above all, JSP technology is about separating content from presentation, foremost in Sun's published set of goals for JSP pages. In fact, JSP design stemmed directly from the complaints of developers who were tired of typing out.println("<HTML><HEAD><TITLE>" + pageInfo.getTitle() + "</TITLE></HEAD>"); into their servlet code. This mixing of hard-coded content with runtime variables presented a horrible burden on servlet developers. It also made making even minor changes to the presentation layer difficult for the developer.

JSP technology addresses this situation by allowing normal HTML pages (and later, WML or other markup language pages) to be compiled at runtime into a Java servlet, essentially mimicking the out.println() paradigm, without requiring the developer to write this code. And it allows you to insert variables into the page that are not interpreted until runtime.

In a JSP page the HTML snippet shown in Listing 2 could look like the example in Listing 3.

<%@ page import="com.ibm.display.PageUtils" %>

<%@ page import="com.ibm.display.PageInfo" %>
<%
PageInfo pageInfo = (PageInfo)session.getAttribute("PAGE_DATA")
%>
<HTML>
<HEAD>
<TITLE>
<%=pageInfo.getTitle()%>
</TITLE>
</HEAD>
<BODY>
<!-- Other HTML content -->
</BODY>
</HTML>

Judging by these initial principles, then, JSP technology (at least in its stated design) would satisfy the first tenet of a presentation technology, as outlined above: that content be separated from presentation.





Tutorial pages:

First published by IBM developerWorks


 3 Votes

You might also want to check these out:


Leave a Comment on "JSP Technology -- Friend or Foe?"
You must be logged in to post a comment.

Link to This Tutorial Page!


GET OUR NEWSLETTERS