jump to navigation

Its Time to RELEARN Java Server Pages January 25, 2008

Posted by Aris in How To.
add a comment

I love web development. I’ve enjoyed doing it with java. However, the popular web frameworks for java complicate what should be simple process. Frameworks like tapestry abandoned JSP for a different methodology and other frameworks like struts and JSF bastardize JSP. I’m proposing jsp afterburner.

HOW TO DEVELOP WITH IT

  1. create a class that implements the afterburner.jsp.JSP class
  2. use protective fields for object you want exposed to the JSP.
  3. create a method (public foo()) that populates the protected fields.
  4. create a jsp with the same name as the method (foo.jsp) that extends the class above.
  5. use the protected methods in the jsp.

HOW TO CONFIGURE

JSP Afterburner requires an entry in the applications web.xml file.

afterburner.jsp.AfterburnerContextListener

HOW IT WORKS

URLs are important to afterburner. Each request that makes use of the framework must explicitly go to the desired JSP file. For example, show.jsp must be the request resource. We use the name of the JSP file to tell us the action method to execute. This convention relieves you from configuring action handlers for all your URLs. This convention allows for multiple JSP files to extend the same class.

  1. Create a JSP file. We’ll call the JSP file show.jsp.
  2. Create a custom class which extend afterburner.jsp.JSP.
  3. We’ll call your custom class custom.Pojo.java.
  4. Add to custom.Pojo a method. Name the method show (public void show(){}.
  5. Show.jsp extends your custom class.
  6. When the url http://HOSTNAME:PORT/show.jsp is requested Afterburner executes the method custom.Pojo.show().

For request that do not map to a rendered jsp, include with the request parameters a value for “exe”. The “exe” value is the method to execute. The method can redirect to another page or continue rendering the default page.