Examples

thumbnail of book cover

Guide to Web Development with Java

Chapter 1

/guide/ViewJsp/ch1/Simple.html
/guide/ViewJsp/ch1/poem.html

Try It: /guide/ch1/poem.html

/guide/ViewJsp/ch1/poem_formatted.html

Try It: /guide/ch1/poem_formatted.html

/guide/ViewJsp/ch1/OnePage/SimpleForm.html

Try It: /guide/ch1/OnePage/SimpleForm.html

/guide/ViewJsp/ch1/simple_web_xml.html
/guide/ViewJsp/ch1/OnePage/First.jsp

Try It: /guide/ch1/OnePage/First.jsp

/guide/ViewJsp/ch1/OnePage/FormInitialized.jsp

Try It: /guide/ch1/OnePage/FormInitialized.jsp

/guide/ViewJsp/ch1/OnePage/FormInitializedBad.jsp

Try It: /guide/ch1/OnePage/FormInitializedBad.jsp

Source for the JSP with an initialized form.
Servlet for the JSP with an initialized form.

Chapter 2

/guide/ViewJsp/ch2/TwoPages/Simple/Edit.jsp
/guide/ViewJsp/ch2/TwoPages/Simple/Confirm.jsp

Try It: /guide/ch2/TwoPages/Simple/Edit.jsp

/guide/ViewJsp/ch2/TwoPages/Error/Confirm.jsp

Try It: /guide/ch2/TwoPages/Error/Edit.jsp

/guide/ViewJsp/ch2/TwoPages/Confirm.jsp

Try It: /guide/ch2/TwoPages/Edit.jsp

/guide/ViewJsp/ch2/ThreePages/Process.jsp
/guide/ViewJsp/ch2/ThreePages/Confirm.jsp

Try It: /guide/ch2/ThreePages/Edit.jsp

/guide/ViewJsp/ch2/jspController/Controller.jsp
/guide/ViewJsp/ch2/jspController/Edit.jsp
/guide/ViewJsp/ch2/jspController/Confirm.jsp
/guide/ViewJsp/ch2/jspController/Process.jsp

Try It: /guide/ch2/jspController/Controller.jsp

/guide/ViewJsp/ch2/servletController/Edit.jsp
/guide/ViewJsp/ch2/servletController/Confirm.jsp
/guide/ViewJsp/ch2/servletController/Process.jsp
/guide/ViewClass/ch2/servletController/Controller.java
Servlet definition and mapping for first controller

Try It: /guide/ch2/servletController/Controller

/guide/ViewClass/ch2/servletController/annotated/Controller.java

Try It: /guide/ch2/servletController/annotated/Controller

Chapter 3

/guide/ViewClass/ch3/startExample/Controller.java
/guide/ViewJsp/ch3/startExample/Edit.jsp
/guide/ViewJsp/ch3/startExample/Confirm.jsp
/guide/ViewJsp/ch3/startExample/Process.jsp

Try It: /guide/ch3/startExample/Controller

/guide/ViewClass/ch3/dataBean/RequestData.java
/guide/ViewClass/ch3/dataBean/Controller.java
/guide/ViewJsp/ch3/dataBean/Edit.jsp
/guide/ViewJsp/ch3/dataBean/Confirm.jsp
/guide/ViewJsp/ch3/dataBean/Process.jsp

Try It: /guide/ch3/dataBean/Controller

/guide/ViewClass/ch3/defaultValidate/RequestDataDefault.java
/guide/ViewClass/ch3/defaultValidate/Controller.java

Try It: /guide/ch3/defaultValidate/Controller

/guide/ViewClass/ch3/sharedVariable/error/Controller.java
/guide/ViewJsp/ch3/sharedVariable/Edit.jsp

Try It: /guide/ch3/sharedVariable/error/Controller

/guide/ViewClass/ch3/sharedVariable/Controller.java

Try It: /guide/ch3/sharedVariable/Controller

/guide/ViewClass/ch3/reorganised/HelperBase.java
/guide/ViewClass/ch3/reorganised/ControllerHelper.java
/guide/ViewClass/ch3/reorganised/Controller.java
/guide/ViewJsp/ch3/reorganised/Edit.jsp
/guide/ViewJsp/ch3/reorganised/Confirm.jsp
/guide/ViewJsp/ch3/reorganised/Process.jsp

Try It: /guide/ch3/reorganised/Controller

Chapter 4

/guide/ViewSource/log4j-1.2.16.jar
/guide/ViewClass/shared/InitLog4j.java
/guide/ViewSource/commons-collections-3.2.1.jar
/guide/ViewSource/commons-logging-1.1.1.jar
/guide/ViewSource/commons-beanutils-1.8.3.jar

/guide/ViewClass/ch4/enhanced/ControllerHelper.java
/guide/ViewClass/shared/HelperBaseCh4.java
/guide/ViewClass/shared/ButtonMethod.java
/guide/ViewClass/ch4/enhanced/Controller.java
/guide/ViewClassJsp/ch4/enhanced/Edit.jsp
/guide/ViewClassJsp/ch4/enhanced/Confirm.jsp
/guide/ViewClassJsp/ch4/enhanced/Process.jsp
Servlet mapping for the enhanced controller
Servlet mapping for the InitLog4j servlet

Try It: /guide/ch4/enhanced/Controller

Chapter 5

Try It: /guide/ch5/TestRegEx

/guide/ViewSource/hibernate-validator-4.2.0.Final.jar
/guide/ViewSource/hibernate-validator-annotation-processor-4.2.0.Final.jar
/guide/ViewSource/validation-api-1.0.0.GA.jar
/guide/ViewSource/slf4j-api-1.6.4.jar

There is an error in the code for the book for the RequestDataRequired bean. The regular expressions for the hobby and aversion have an extra character in them. Both of the regular expressions should be regexp=".*\\S.*". The source code on this web site has been corrected.
/guide/ViewClass/ch5/requiredValidation/RequestDataRequired.java
/guide/ViewClass/shared/HelperBaseCh5.java
/guide/ViewClass/ch5/requiredValidation/ControllerHelper.java
/guide/ViewClass/ch5/requiredValidation/Controller.java
/guide/ViewClassJsp/ch5/requiredValidation/Edit.jsp
/guide/ViewClassJsp/ch5/requiredValidation/Confirm.jsp
/guide/ViewClassJsp/ch5/requiredValidation/Process.jsp

As noted above, there is an error in the RequestDataRequired code in the book. If the code from the book is used, then the hobby would have to start with the letter 'c' and the aversion would have to start with the letter 'd'. The corrected code only checks that the hobby and aversion are not empty.
Try It: /guide/ch5/requiredValidation/Controller

/guide/ViewClass/ch5/postServlet/Controller.java
/guide/ViewClass/ch5/postServlet/ControllerHelper.java
/guide/ViewClassJsp/ch5/postServlet/Edit.jsp
/guide/ViewClassJsp/ch5/postServlet/Confirm.jsp
/guide/ViewClassJsp/ch5/postServlet/Process.jsp

Try It: /guide/ch5/postServlet/Controller

/guide/ViewSource/antlr-2.7.6.jar
/guide/ViewSource/c3p0-0.9.1.jar
/guide/ViewSource/cglib-2.2.jar
/guide/ViewSource/commons-collections-3.2.1.jar
/guide/ViewSource/commons-logging-1.1.1.jar
/guide/ViewSource/dom4j-1.6.1.jar
/guide/ViewSource/hibernate-commons-annotations-4.0.1.Final.jar
/guide/ViewSource/hibernate-core-4.1.1.Final.jar
/guide/ViewSource/hibernate-jpa-2.0-api-1.0.1.Final.jar
/guide/ViewSource/javassist-3.12.0.GA.jar
/guide/jboss-logging-3.0.1.GA.jar
/guide/ViewSource/jboss-transaction-api_1.1_spec-1.0.0.Final.jar
/guide/ViewSource/jta-1.1.jar
/guide/ViewSource/log4j-1.2.16.jar
/guide/ViewSource/mysql-connector-java-5.0.6-bin.jar
/guide/ViewSource/jstl.jar
/guide/ViewSource/standard.jar

/guide/ViewClass/shared/HibernateHelper.java
/guide/ViewClass/shared/PersistentBase.java
/guide/ViewClass/ch5/persistentData/RequestDataPersistent.java
/guide/ViewClass/ch5/persistentData/Controller.java
/guide/ViewClass/ch5/persistentData/ControllerHelper.java
/guide/ViewClassJsp/ch5/persistentData/Edit.jsp
/guide/ViewClassJsp/ch5/persistentData/Confirm.jsp
/guide/ViewClassJsp/ch5/persistentData/Process.jsp
/guide/ViewJsp/validator/Min.java
/guide/ViewJsp/validator/MinValidator.java
/guide/ViewJsp/validator/Max.java
/guide/ViewJsp/validator/MaxValidator.java
/guide/ViewClass/shared/WebappListener.java
Example xml for persistent servlet
/guide/ViewJsp/ch5/persistent_mapping_xml.txt
/guide/ViewJsp/ch5/listener_mapping_xml.txt

Try It: /guide/ch5/persistentData/Controller

/guide/ViewJsp/ch5/hibernate.cfg.xml
/guide/ViewClass/ch5/persistentData/configure/Controller.java
/guide/ViewClass/ch5/persistentData/configure/ControllerHelper.java
/guide/ViewJsp/ch5/configure_mapping_xml.txt

Chapter 6

/guide/ViewJsp/ch6/test.css
/guide/ViewJsp/ch6/test.css.html

Try It: /guide/ch6/test.css.html

/guide/ViewJsp/ch6/custom.css
/guide/ViewJsp/ch6/custom.html

Try It: /guide/ch6/custom.html

/guide/ViewClass/ch6/complexForm/RequestDataComplex.java
/guide/ViewClass/ch6/complexForm/ControllerHelper.java
/guide/ViewClass/ch6/complexForm/Controller.java
/guide/ViewClassJsp/ch6/complexForm/Edit.jsp
/guide/ViewClassJsp/ch6/complexForm/Confirm.jsp
/guide/ViewClassJsp/ch6/complexForm/Process.jsp

Try It: /guide/ch6/complexForm/Controller

/guide/ViewClass/shared/HelperBaseCh6.java
/guide/ViewClass/shared/AttributeType.java
/guide/ViewClass/shared/SetByAttribute.java
/guide/ViewClass/ch6/complexInit/RequestDataInit.java
/guide/ViewClass/ch6/complexInit/ControllerHelper.java
/guide/ViewClass/ch6/complexInit/Controller.java
/guide/ViewClassJsp/ch6/complexInit/Edit.jsp
/guide/ViewClassJsp/ch6/complexInit/Confirm.jsp
/guide/ViewClassJsp/ch6/complexInit/Process.jsp

Try It: /guide/ch6/complexInit/Controller

/guide/ViewClass/ch6/complexValid/ComplexDataValid.java
/guide/ViewClass/ch6/complexValid/ControllerHelper.java
/guide/ViewClass/ch6/complexValid/Controller.java
/guide/ViewClassJsp/ch6/complexValid/Edit.jsp
/guide/ViewClassJsp/ch6/complexValid/Confirm.jsp
/guide/ViewClassJsp/ch6/complexValid/Process.jsp

Try It: /guide/ch6/complexValid/Controller

/guide/ViewClass/ch6/complexPersistent/ComplexDataPersistent.java
/guide/ViewClass/ch6/complexPersistent/ControllerHelper.java
/guide/ViewClass/ch6/complexPersistent/Controller.java
/guide/ViewClassJsp/ch6/complexPersistent/Edit.jsp
/guide/ViewClassJsp/ch6/complexPersistent/Confirm.jsp
/guide/ViewClassJsp/ch6/complexPersistent/Process.jsp
Servlet mapping for the peristent controller

Try It: /guide/ch6/complexPersistent/Controller

Chapter 7

/guide/ViewClassJsp/ch7/accountLogin/Login.jsp
/guide/ViewClassJsp/ch7/accountLogin/Edit.jsp
/guide/ViewClassJsp/ch7/accountLogin/Confirm.jsp
/guide/ViewClassJsp/ch7/accountLogin/Process.jsp
/guide/ViewClass/ch7/accountLogin/RequestDataAccount.java
/guide/ViewClass/ch7/accountLogin/ControllerHelper.java
/guide/ViewClass/ch7/accountLogin/Controller.java
Servlet mapping for the login controller

Try It: /guide/ch7/accountLogin/Controller

/guide/ViewClassJsp/ch7/accountRemove/Login.jsp
/guide/ViewClassJsp/ch7/accountRemove/Edit.jsp
/guide/ViewClassJsp/ch7/accountRemove/Confirm.jsp
/guide/ViewClassJsp/ch7/accountRemove/Process.jsp
/guide/ViewClass/ch7/accountRemove/ControllerHelper.java
/guide/ViewClass/ch7/accountRemove/Controller.java
Servlet mapping for the account removal controller

Try It: /guide/ch7/accountRemove/Controller

/guide/ViewClass/shared/CookieUtil.java
/guide/ViewClass/ch7/cookie/Controller.java
/guide/ViewClass/ch7/cookie/ControllerHelper.java
/guide/ViewClassJsp/ch7/cookie/ShowCookies.jsp

Try It: /guide/ch7/cookie/Controller

/guide/ViewClassJsp/ch7/accountCookie/Login.jsp
/guide/ViewClassJsp/ch7/accountCookie/Edit.jsp
/guide/ViewClassJsp/ch7/accountCookie/Confirm.jsp
/guide/ViewClassJsp/ch7/accountCookie/Process.jsp
/guide/ViewClass/ch7/accountCookie/ControllerHelper.java
/guide/ViewClass/ch7/accountCookie/Controller.java
Servlet mapping for the account cookie controller

Try It: /guide/ch7/accountCookie/Controller

/guide/ViewClass/ch7/catalogue/CatalogueItem.java
/guide/ViewClass/ch7/catalogue/CreateCatalogue.java
/guide/ViewClass/ch7/catalogue/ShoppingCart.java
/guide/ViewClass/ch7/catalogue/ControllerHelper.java
/guide/ViewClass/ch7/catalogue/Controller.java
/guide/ViewClassJsp/ch7/catalogue/BrowseLoop.jsp
/guide/ViewClassJsp/ch7/catalogue/Cart.jsp
/guide/ViewClassJsp/ch7/catalogue/Process.jsp
/guide/ViewJsp/catalogue.css

Try It: /guide/ch7/catalogue/Controller

/guide/ViewClass/ch7/catalogue/persistent/CatalogueItemPersist.java
/guide/ViewClass/ch7/catalogue/persistent/CreateCataloguePersist.java
/guide/ViewClass/ch7/catalogue/persistent/ShoppingCartPersist.java
/guide/ViewClass/ch7/catalogue/persistent/ControllerHelper.java
/guide/ViewClass/ch7/catalogue/persistent/Controller.java
/guide/ViewClassJsp/ch7/catalogue/persistent/Login.jsp
/guide/ViewClassJsp/ch7/catalogue/persistent/BrowseLoop.jsp
/guide/ViewClassJsp/ch7/catalogue/persistent/Process.jsp
/guide/ViewClassJsp/ch7/catalogue/persistent/SaveCart.jsp
Servlet mapping for the persistent catalogue controller

Try It: /guide/ch7/catalogue/persistent/Controller

Chapter 8

Due to the web services agreements, I am only allowed to use the services for personal use. I am not allowed to create a public interface to access these services. I have provided links to the source code, but there are no Try It links for this chapter.

The web services examples rely on the code generated by the IDE for the web service. The coded referenced here is only the interface that accesses the generated code.

/guide/ViewClassJsp/ch8/services/google/Edit.jsp
/guide/ViewClassJsp/ch8/services/google/Confirm.jsp
/guide/ViewClassJsp/ch8/services/google/Process.jsp
/guide/ViewClass/ch8/services/google/ControllerHelper.java
/guide/ViewClass/ch8/services/google/Controller.java

/guide/ViewClass/ch8/services/fedex/ControllerHelper.java /guide/ViewClass/ch8/services/fedex/Controller.java /guide/ViewClass/ch8/services/fedex/FedexAddress.java /guide/ViewClass/ch8/services/fedex/FedexDimensions.java /guide/ViewClass/ch8/services/fedex/RequestDataFedex.java

/guide/ViewClass/ch8/services/paypal/ControllerHelper.java /guide/ViewClass/ch8/services/paypal/Controller.java

Appendix

/guide/ViewClass/shared/HibernateHelper.java
/guide/ViewClass/shared/PersistentBase.java
/guide/ViewClass/shared/InitLog4j.java
/guide/ViewClass/shared/CookieUtil.java
/guide/ViewClass/shared/AttributeType.java
/guide/ViewClass/shared/DataCollections.java
/guide/ViewClass/shared/ButtonMethod.java
/guide/ViewClass/shared/SetByAttribute.java
/guide/ViewClass/shared/HelperBaseCh4.java
/guide/ViewClass/shared/HelperBaseCh5.java
/guide/ViewClass/shared/HelperBaseCh6.java
/guide/ ViewClass/shared/WebappListener.java

This JAR file contains all of the .java and .class files from the shared package. Add this to the lib directory of the web application to access all of the files from the shared package. /shared.jar


Contact the author