Best method to load a JSP into a DIV?

Posted on 2008-11-10
Last Modified: 2013-11-11
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

Question by:delux220
    1 Comment
    LVL 26

    Accepted Solution

    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).

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    JavaScript Error: Unexpected Token 2 32
    Javascript newbie 5 30
    GPS save in database 19 20
    Issues with signature 19 19
    This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now