Abstract
Presentation for The Southern Illinois Web Developers Association (SIWebDev) Tuesday October 3rd, 2005 7:00 - 8:15 PM
Table of Contents
List of Figures
According to the official DocBook web site,
DocBook is a general purpose XML and SGML document type particularly well suited to books and papers about computer hardware and software (though it is by no means limited to these applications). | ||
| --DocBook.org | ||
Table of Contents
package com.javaclimber.silwebdev;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class HelloWorldServlet extends HttpServlet {
public void init() throws ServletException {
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Hello World</title><head>");
out.println("<body>");
out.println("<h1>Hello World!!!</h1>");
out.println("<br/>");
out.println("Today is "+new java.util.Date());
out.println("</body>");
out.println("</html>");
}
public void doPost(HttpServletRequest arg0, HttpServletResponse arg1)
throws ServletException, IOException {
doGet(arg0, arg1);
}
}
<html>
<head><title>Bad JSP</title><head>
<body>
<%String[][] tableData={{"header-row1, col1", "header-row1, col2", "header-row1, col3"},
{"row2, col1", "row2, col2", "row2, col3"},
{"row3, col1", "row3, col2", "row3, col3"}
};%>
<table>
<%for(int i=0;i<tableData.length;i++){%>
<tr>
<%for(int j=0;j<tableData[i].length; j++){%>
<%=((i==0)?"<th>":"<td>")%><b><%=tableData[i][j]%></b><%=((i==0)?"</th>":"</td>")%>
<%}%>
</tr>
<%}%>
</body>
</html>
<%@ taglib uri="/myTag" prefix="myTag" %>
<html>
<head><title>Custom Tag Example</title><head>
<body>
<form>
<select name="dropDown">
<myTag:iterate id="item" name="myDropDownValues">
<option value='<myTag:write name="item" property="name"/>' <myTag:displaySelected name="item"> >
<myTag:write name="item" property="name"/>
</option>
</myTag:iterate>
</select>
<input type='submit'/>
</form>
</body>
</html>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>
<head><title>JSTL Table of Pictures Example</title><head>
<body>
<table>
<c:forEach var="item" items="${PICS_AL}" varStatus="status">
<c:set var="rowIndex" value="${status.index%NUM_PICS_PER_ROW}" />
<c:if test="${rowIndex==0}">
<tr>
</c:if>
<td>
<center>
<img src='<c:out value="${item.pic}"/>'/>
<br/>
<c:if test='${!empty item.picDesc}'>
<br/>
<c:out value="${item.picDesc}"/>
</c:if>
</center>
</td>
<c:if test="${rowIndex==NUM_PICS_PER_ROW-1}">
</tr>
</c:if>
</c:forEach>
<c:if test="${rowIndex lt NUM_PICS_PER_ROW-1}">
<c:forEach begin="${rowIndex+1}" end="${NUM_PICS_PER_ROW-1}" step="${1}">
<c:set var="rowIndex" value="${rowIndex+1}"/>
<td> </td>
<c:if test="${rowIndex==NUM_PICS_PER_ROW-1}">
</tr>
</c:if>
</c:forEach>
</c:if>
</table>
</body>
</html>
Table of Contents
Table of Contents
package com.javaclimber.siwebdev.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
public class ShowIndexAction extends Action {
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm, HttpServletRequest request,
HttpServletResponse response) {
try {
doSomething();
} catch (SomeException e) {
ActionMessages errors=new ActionMessages();
errors.add("myerror",new ActionMessage("myerror.errors"));
saveMessages(request,errors);
return actionMapping.findForward("fail");
}
return actionMapping.findForward("success");
}
}
<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd"> <struts-config> <form-beans> <form-bean name="logonForm" type="app.LogonForm"/> </form-beans> <action-mappings> <action path="/Welcome" forward="/pages/Welcome.jsp"/> <action path="/Logon" forward="/pages/Logon.jsp"/> <action path="/LogonSubmit" type="app.LogonAction" name="logonForm" scope="request" validate="true" input="/pages/Logon.jsp"> <forward name="success" path="/pages/Welcome.jsp"/> <forward name="failure" path="/pages/Logon.jsp"/> </action> <action path="/Logoff" type="app.LogoffAction"> <forward name="success" path="/pages/Logoff.jsp"/> </action> </action-mappings> <message-resources parameter="resources.application"/> </struts-config>
<%@ taglib uri="struts/html-el" prefix="html" %>
<html>
<body>
<html:form action="insertEmployee" focus="name">
<table>
<tr>
<td >Name:</td>
<td><html:text property="name"/></td>
</tr>
<tr>
<td>Age:</td>
<td><html:text property="age"/></td>
</tr>
<tr>
<td>Department:</td>
<td>
<html:select name="employeeForm" property="department">
<html:options collection="departments" property="id" labelProperty="description"/>
</html:select>
</td>
</tr>
</table>
<html:submit>Submit</html:submit>
</html:form>
</body>
</html>
<field property="age" depends="required,long,longRange">
<arg0 key="employee.age"/>
<arg1 name="longRange" key="${var:min}" resource="false"/>
<arg2 name="longRange" key="${var:max}" resource="false"/>
<var><var-name>min</var-name><var-value>18</var-value></var>
<var><var-name>max</var-name><var-value>65</var-value></var>
</field>
<field property="customeremail" depends="email">
<arg0 key="customer.email"/>
</field>
<global>
<constant>
<constant-name>zip</constant-name>
<constant-value>^\d{5}(-\d{4})?$</constant-value>
</constant>
</global>
<field property="zip" depends="required,mask">
<arg0 key="registrationForm.zippostal.displayname"/>
<var>
<var-name>mask</var-name>
<var-value>${zip}</var-value>
</var>
</field>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
"http://struts.apache.org/dtds/tiles-config_1_1.dtd">
<tiles-definitions>
<definition name="baseLayout" path="/layouts/basiclayout.jsp">
<put name="header" value="/includes/header.jsp" />
<put name="menu" value="/includes/menu.jsp" />
<put name="footer" value="/includes/footer.jsp" />
</definition>
<definition name="/welcome.page" extends="baseLayout">
<put name="title" value="Main Menu" />
<put name="body" value="/welcome.jsp" />
</definition>
<tiles-definitions>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ include file="/includes/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Andy Nilson Site - <tiles:getAsString name="title"/></title>
<link rel="stylesheet" type="text/css" href="<html:rewrite page='/css/global.css'/>" />
<c:if test="${noCache == true}">
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
</c:if>
</head>
<body>
<table border="0" width="100%" cellspacing="5">
<tr>
<td colspan="2"><tiles:insert attribute="header" /></td>
</tr>
<tr>
<td valign="top"><tiles:insert attribute='menu'/></td>
</tr>
<tr>
<td style="width:100%"><hr/></td>
</tr>
<tr>
<td valign="top" align="left"><tiles:insert attribute='body' /></td>
</tr>
<tr>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td colspan="2" class="center"><tiles:insert attribute="footer" /></td>
</tr>
</table>
</body>
</html>
Table of Contents