Web technologies -- Laboratory 8 -- 2007-2008 -- info.uvt.ro

From Wikiversity
Important! These pages are somehow outdated and it is recommended to consult the newer version at Web technologies -- 2009-2010 -- info.uvt.ro (by Marc Frâncu).

Navigation[edit]

JSP -- JavaServer Pages[edit]

References[edit]

Tutorials[edit]

Discussion points[edit]

  • comparisons between JSP and:
    • servlets;
    • static HTML;
  • content:
    • static;
    • dynamic;
  • syntax:
    • standard;
    • XML based;
  • constructs:
    • static:
<html>
    <head>...</head>
    <body>...</body>
</html>
    • scripting:
      • expressions:
<%= java expression %>
<jsp:expression>java expression</jsp:expression>
      • scriptlet (code):
<% java code %>
<jsp:scriptlet>java code</jsp:scriptlet>
      • declaration:
<%! java code %>
<jsp:declaration>java code</jsp:declaration>
    • directives (executed at compile-time):
<%@ page attribute="value" %>
<jsp:directive.page attribute="value" />
<%@ include file="url" %>
<jsp:directive.include file="url" />
      • attribute can be import, contentType, isThreadSafe, etc.
    • actions (executed at run-time):
<jsp:include page="url" />

<jsp:forward page="url" />

<jsp:useBean id="name" class="bean_class" />
<jsp:getProperty name="..." property="... />
<jsp:setProperty name="..." property="..." value="..." param="..." />

<jsp:element name="...">
    <jsp:attribute name="...>
        value
    </jsp:attribute>
    <jsp:body>
        body
    </jsp:body>
</jsp:element>
  • predifined objects:
    • page -- is the same as this;
    • pageContext;
    • request and response -- the same as in normal servlets;
    • session -- user session if available;
    • application -- servlet.getServletConfig().getContext();
    • config -- servlet.getServletConfig();
    • etc.;
  • tag libraries:
    • taglib directive:
<%@ taglib prefix="my" uri="/my.dld" %>
    • tag handler;
    • tld -- tag library descriptor;
  • translation and compilation process;

Assignment[edit]

Starting from the previous assignment, create a new web application that should use JSP instead of hand-written servlets.

Like the previous assignment this must be deployed on the Tomcat server under the name <username>-assignment-07 and also committed on the SVN server.

Reminder:

  • assignment-05 required to implement a web application, using servlets, that allowed the user to manage a simple database, the records being kept inside a Java data structure (like ArrayList, HashMap, etc.);
  • assignment-06 had the same requirements -- that is using servlets to ... -- but this time the records should be kept inside a relational database by using JDBC -- H2 was the database to be used;
  • assignment-07 requires the replacement of the servlet with JSP pages, but the data still should be kept inside a relational database by using JDBC;

Ciprian Dorin Craciun, 2007-11-28, ccraciun@info.uvt.ro