Spring Dependency Injection

Spring provides dependency injection capabilities using Setter injection, or Constructor injection. Object models can then be declaratively represented in XML. Here’s a Setter injection based example using the property element: <bean name="shaker" class="net.bencode.model.Shaker"> <property name="proteinPowder" ref="proteinPowder" /> </bean> <bean name="proteinPowder" class="net.bencode.model.ProteinPowder"> <property name="grams" ref="120" /> </bean> Or if XML isn’t your thing, annotations are also an option, using a combination of @Component and @Autowired. @Component public class Shaker { @Autowired private ProteinPowder proteinPowder; ... } @Component public class ProteinPowder { private int grams; ... } Constructor injection is similarly defined using the constructor-arg element. The following example works if the Shaker class has a constructor that takes in a ProteinPowder instance: ...

April 25, 2013 · 1 min

JavaServer Pages

As a follow up to previous post [The Servlet API]({% post_url 2007-02-20-servlet-api %}), this post aims to sweeps over some fundamentals of JSP, a technology which thanks to its simple yet extensible design, still to this day, underpins many modern web application frameworks. JavaServer Pages (JSP) is a technology that helps software developers create dynamically generated web pages based on HTML, XML, or other document types. Released in 1999 by Sun Microsystems. ...

February 28, 2007 · 8 min

The Servlet API

As you start out building Java web applications, you soon find that it sit upon several well designed building blocks. Once the penny drops, and an intuition about these building blocks is gained, creating web apps on Java becomes a delight. Two key, top level concepts are the mighty Servlet API and JavaServer Pages (JSP). These are deployed to a Web container, also commonly referred to a Servlet (or Web) container. ...

February 20, 2007 · 11 min