Best method to load a JSP into a DIV?

Hi. I'm new to experts-exchange, but I'm working on a Start-up, so I figure I should give it a shot..

The website I'm working on needs to have certain features always on the page. For example, we may want a chat widget to be constantly available to users, while browsing our site. Instead of loading new pages and having these kinds of features appear on each page, I was thinking of having one main DIV that would have complex content loaded into it (please stop me if this is already a bad design).

Anyway, what I have done so far, is I created the main div, and called the Prototype Ajax.Updater to make an AJAX call to a jsp, so that the response (the contents of the jsp) are written into the div. Code below:

I have tried this with only a very simple jsp containing a div with some text inputs, and it does work, and I am able to control pieces of it from the "outer" page with javascript. However, I'd like to have someone's opinion on this, because I'm thinking there must be huge limitations to this.

Can anyone point me in the right direction?? If this is not clear as to what I am trying to achieve, I can clarify..

Thanks in advance.
function test(div) {
                new Ajax.Updater({ success: $(div).identify() }, '/wom_app/write.jsp', {
                  parameters: { action: 'test'}

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There are many ways to handle common page elements on all pages.  I haven't personally seen yours, but it seems okay.

I don't think there are any limitations in the sense that it won't work -- file size is the same as for normal Web pages, and so on.

However, the level of computing that will occur for common page elements -- that is, on every page? -- seems high.  Most people use a server-side solution that collects the common pieces and then sends the page to the browser.  Browser requests to the server are faster than Ajax requests, and you are setting up an architecture where every page will make one or more Ajax requests just for the basic headers (or wherever you put the links to chat, etc.).

So I would imagine the reason to use Ajax to build your pages is that you don't have a dynamic page building architecture on the server side.  If your whole site is JSP or servlets, that isn't true.  That leads me to think you're using HTML only on the server side for portions of the site?

Some people use Apache and insert common headers on all requests of a certain type.   Others use cookies for simple pieces of data (like your "text inputs") and Javascript to place the data correctly in the headers on the page.  You can also use shtml to include common headers from the server.  If you're using IIS, there are some .Net features similar to the Apache method mentioned above.

All that being said, you could still go ahead with your architecture.  You could check some sites that make a lot of use of Ajax, like Google (logged in, using mail and calendar), Digg (I think), etc.  See what you think of the user experience (try a few browsers).  My experience is that sites with a heavy use of Ajax are oddly slow.  However, they're doing a lot more than you're talking about, I think, so your site might not suffer from those delays.

Given that your technical architecture is okay, you might consider doing some performance testing.  Test the server, and test the browser performance with some basic pages, with small numbers of hits and with a heavy load.  That kind of testing is not easy to set up, but it will give you peace of mind that your architecture will work for you as your site becomes very successful (:o).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.