Posts

Showing posts from February, 2008

Troy Quotes

"If they ever tell my story, Let them say that i walked with giants. Men rise and fall like the winter wheat, But these names will never die. Let them say i lived in the time of Hector, Tamer of Forces. Let them say i lived in the time of Achiles." Odysseus

One template file for all pages using Servlets and JSP

Image
One of my recent tasks was making a new skin for one of our websites. the site had a common header, left side area and right side area that are to be shared among all pages. we used to include file for "header", "left side", "right side" in each of the pages.. it wasn't that pretty i know. I wanted to think of something better where i can define the template in exactly one file and i do not have to include that file on every new page i add. something pretty much close the RubyOnRails "<% yield %>' directive to import the page content inside the template. i finally managed to do it. I'll use two simple pages to illustrate the concept: mahmoud.jsp and index.jsp what we want is to have each of the two pages displayed in a layout where is one header, banners and so. which will look like the following. I was able to do this using a servlet that intercepts the request. and loads the template jsp file and pass the desired page to as a param