• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1964
  • Last Modified:

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.
delux220
function test(div) {
                new Ajax.Updater({ success: $(div).identify() }, '/wom_app/write.jsp', {
                  parameters: { action: 'test'}
                });
 
            }

Open in new window

0
delux220
Asked:
delux220
1 Solution
 
mrcoffee365Commented:
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).
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now