Chapter 11 Web Deployment

Web App Folder Structure

/myApp (.jsp , .html ) ==> /WEB-INF ==> /lib ( jar files)
/classes (class files)
/tags ( tag files)
(TLD files)

*WAR file (Web Archive) - This is in fact jar file and contains all application files including WEB-INF.
One thing special is WAR has /META-INF/MANIFEST.MF gives you deploy time check for classes & packages that WAR depends on.

*Direct access to files under WEB-INF and META-INF will show 404 error.

* <servet><url-pattern> matching order

  1. Exact match : /Beer/SelectBeear.do
  2. Directory match : /Beer/*
  3. Extension match : *.do

The most specific match always win.

*Welcome files

<welcome-file-list>
	<welcome-file>index.html</welcome-file>
	<welcome-file>default.jsp</welcome-file>
</welcome-file-list>

Read the rest of this entry »

Chapter 10 Custom Tag Development

(*) Tag File
Store the tag files in /WEB-INF/tags folder.
The name of the tag file will become the tag name. (Header.tag ==> Header will be the name of the tag in JSP)

JSP usage

<%@taglib prefix="mytags" tagdir="/WEB-INF/tags" %>
  • note that the tagdir attribute used instead of uri attribute
  • tagdir value is the folder where the tag files are located
<mytags:Header subtitle="Welcome" />
  • Header was the name of the file. (Header.tag)

Header.tag

<em><strong>${subtitle}</strong></em>

Read the rest of this entry »

Chapter9 using JSTL

JSTL is not part of JSP 2.0 spec. (jstl.jar & standard.jar copy needed)

(*) <c:out>

<c:out value='${pageContent.currentTip}' escapeXml="true" default="No tip" />
  • escapeXML: when true, escapes HTML special characters (<,>,&,’,”) and default value is true.
  • default: attribute is to show default value when the value attribute data is null. Or default value can be defined in the body.

(*) <c:forEach>

<c:forEach var="movie" items="${movieList}" varStatus="info">
	<tr><td>${info.count}</td><td>${movie}</td></tr>
</c:forEach>
  • Items: array, collection, map, comma delimited string
  • varStatus: extra object that you can get count information.
  • <c:forEach> can be nested.

(*) <c:if>

<c:if test="${userType eq 'member'}" >
	<jsp:include page="input.jsp" />
</c:if>

Read the rest of this entry »