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
- Exact match : /Beer/SelectBeear.do
- Directory match : /Beer/*
- 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>
[SCWCD] Cram Sheet 7 - Custom Tag Development
April 29, 2008
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>[SCWCD] Cram Sheet 6 - using JSTL
April 26, 2008
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>