Modify Tomcat startup script in Eclipse

March 2, 2008

Right-click on server’s name -> Run As -> Open Run Dialog -> Arguments


Grails quickstart

August 3, 2007

A quick start guide to Grails

There was a period of time when Java developers can only envy the RoR developers for completing the day’s work by lunch time. Not anymore, for we have Grails to the rescue!

After exploring Grails for an hour, I’m really impressed by its fuss-free scaffolding. (In an hour, I had enough time to touch on the basics and to write this post. Ha ha :) ) Don’t be convinced by me, you’ve gotta try it for yourself to believe it.

Ok, first of all, we will need to install Grails, which is nothing more than just:

  • Download and unzip Grails.
  • Define a GRAILS_HOME environment variable to point to the unzipped Grails directory.
  • Add $GRAILS_HOME/bin to your $PATH.

Installation is complete!

Now let’s begin writing our very first “real-world” application. For starters, our application will help to manage seminars and registrations. Execute these steps on your shell:

  • grails create-app myapp
  • cd myapp
  • grails create-domain-class Seminar
  • grails create-domain-class Registration
  • Edit myapp/grails-app/domain/Seminar.groovy:
    • class Seminar {
      String title
      Date startDateTime
      String city
      Float cost
      Boolean mealsProvided
      static hasMany = [registrations:Registration]
      }
  • Edit myapp/grails-app/domain/Registration.groovy:
    • class Registration {
      String name
      Date dateOfBirth
      String gender
      Seminar seminar
      }
  • grails generate-all Seminar
  • grails generate-all Registration
  • grails run-app

That’s all the code you need to write to set up the scaffolding! Let’s enjoy the fruits of our labour by browsing to http://localhost:8080/myapp. You’ll notice this scaffolding automatically includes:

  • CRUD functionalities for both our Seminar and Registration domain classes.
  • In the Registration data entry page, the Seminar field is rendered as a dropdown list of all Seminar objects.
  • In the Seminar data entry page, the MealsProvided field is rendered as a checkbox.

Here are some screen shots of the scaffolding:

grails2.jpg

grails1.jpg

Oh, did I mention the one hour also includes a trip to the kitchen to reward myself with a cuppa coffee? :)

For further reading, I recommend this wonderful and FREE e-book: Getting Started with Grails by Jason Rudolph


WURFL

May 29, 2007

The WURFL is an XML configuration file which contains information about capabilities and features of many mobile devices: http://wurfl.sourceforge.net/index.php


Configuring Jasper

April 17, 2007

Tomcat uses the Jasper JSP Engine to implement JSP specs. From Tomcat 5.5’s docs: http://tomcat.apache.org/tomcat-5.5-doc/jasper-howto.html#Configuration

In particular, a small section configures Tomcat for production:

  • development - To disable on access checks for JSP pages compilation set this to false.
  • genStringAsCharArray - To generate slightly more efficient char arrays, set this to true.
  • modificationTestInterval - If development has to be set to true for any reason (such as dynamic generation of JSPs), setting this to a high value will improve performance a lot.
  • trimSpaces - To remove useless bytes from the response, set this to true.

Refer to the above hyperlink for the full list of configurable settings.