Today, Budi walks us through a refresher and brief overview of server JSP programming. Today's portion covers Servlet technologies, including servlets and Tomcat. This excerpt comes from chapter one of JavaServer Faces Programming, by Budi Kurniawan (McGraw-Hill/Osborne, ISBN 0-07-222983-7, 2004).
In a deployment descriptor (the web.xml file), you can define settings for the application the deployment descriptor describes. This allows you to define context initial parameters that are available to all servlets/JSP pages in that application, register servlets, register listeners, map resources to URLs, and so on. This section explains how you can define context parameters.
Using context parameters can save you from needing to hard-code certain information in the servlet code. This way, if you want to change the information, you will not need to recompile the servlet.
You can specify context parameter name/value pairs that will be available to all servlets/JSP pages in that application using the context-param element. For example, Listing 2 shows a deployment descriptor that contains a servlet called MyServlet, which has two initial parameter name/value pairs: userName/budi and password/secret.
Remember: This is part one of the first chapter of JavaServer Faces Programming, by Budi Kurniawan (McGraw-Hill/Osborne, ISBN 0-07-222983). Stay tuned for part 2 of "Overviews of Java Web Technologies," where we learn about JSP, JavaBeans, and Model 2. Buy this book!