Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

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:
» A critical look at JavaServer Pages servlets as a viable presentation technology
» A bit of history
» The premise
» Segregation vs. integration
» Work vs. rework
» The promise of JSP technology
» Content vs. presentation
» Code vs. markup
» Designer vs. developer
» The problems
» Portability vs. language lock-in
» Mingling vs. independence
» Blurring the line between content and presentation
» Single-processing vs. multi-tasking
» HTML vs. XML
» Summary
» Resources


First published by IBM developerWorks


 | Bookmark
Related Tutorials:
» All about JAXP, Part 1
» Make Database Queries Without the Database
» Load List Values for Improved Efficiency
» 2 Ways To Implement Session Tracking
» A Simple Way to Read an XML File in Java
» Develop Aspect-Oriented Java Applications with Eclipse and AJDT

Ask A Question
characters left.