Adding Your Design & Website Functionality to Your Servlet Driven Site
Ok so we have content but for those of you who have been playing the home version you may have glanced at the source code in the browser and noticed we
don't yet have real
HTML yet. For that we are going to create two new classes. I should also note at this point that I have removed all my normal packages
I would use in a web application just to make this tutorial easier to follow. Anyway, I'm going to create a class called PageTop and another called PageBottom. As
you've probably figured out by this point PageTop will contain all of the HTML that precedes the content of our page while the PageBottom contains all of the HTML
code that follows our content. For now we are going to keep it simple, in part three I'll show you how I use these files to make our pages more interactive and
SEO friendly.
So here is our simple PageTop object. Now for those of your
Purists
out there cringing right now I would ask you to hold your opinions until you have had the chance to see part three. I have very good reasons for
the way I do this. Here is our PageBottom object and Here is
our Controller with these two objects added. On a simple
website this would complete the entire servlet code, but many other things can be added such as navbar objects etc. On 99% of my websites this is the most code
you will usually find in my actual servlets, everything else is added within my PageTop & PageBottom objects. But before I leave you (only for a short time) I
would like to point out one of my little tricks
here. If you'll look again at the
PageTop object you will notice I am using my page's name (the same
parameter we grabbed in our servlet and passed to this object) as both my HTML page's title AND my meta keywords tag. By using a keyword rich filename and passing
it into my PageTop, then using the replace method on it (replacing the - with a space) I have just dynamically added my keywords to the URL, the title and the meta tag
all from one parameter! This ensures consistent keyword saturation on two of the most important tags in your page.
We will leave it there for now but in early June we will finish these formatting objects and show a few more tricks of the trade
.... check back then!
Lisa Walker, tothemax1.com | More Testimonials >>