Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 748573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:20:08+00:00 2026-05-14T14:20:08+00:00

I need to use ajax feature to load an external div element (an external

  • 0

I need to use ajax feature to load an external div element (an external jsp file) into the current page. That JSP page contains a dynamic content – e.g. content that is based on values received from the current session.

I solved this problem somehow, but I’m in doubt because I think that my solution is bad , or maybe there is better solution since I’m not expert.

I have three files:

  • Javascript function that is triggered when a TR element is clicked, it requests html data from a servlet:

    $("#inboxtable tbody tr").click(function(){
    
        var trID = $(this).attr('id');
        $.post("event?view=read",{id:trID}, function(data){
            $("#eventContent").html(data); // load external file
        },"html"); // type
    
    });
    
  • The servlet “event” loads the data and generates HTML content using include method :

    String id = request.getParameter("id");
    if (id != null) {
       v.add("Test");
       v.add(id);
       session.setAttribute("readMessageVector", v);
       request.getRequestDispatcher("readMessage.jsp").include(request, response);
    }
    
  • Finally: The external readMessage jsp file looks like this:

    <p>
       Text: ${readMessageVector[0]}
    </p>
    <p>
       ID:   ${readMessageVector[1]}
    </p>
    

    My questions

  • Is this solution good enough to solve this problem – loading external jsp that has dynamic content ?

  • Is there a better solution ? such as putting all DIVs elements in the same file instead of loading them from an external file , and showing or hiding those elements using javascript/jquery in the same file ? In this way , I will only use the JSON ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:20:09+00:00Added an answer on May 14, 2026 at 2:20 pm

    This solution seems fine to me. If you start to make lots of different AJAX calls in the future, you would be better returning a lightweight response such as JSON from the jsps – this will save bandwidth and jQuery can be used to generate the bulky HTML markup.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While debugging jQuery apps that use AJAX, I often have the need to see
I've made an application that makes full use of ajax, and what I need
I need to use YQL (Yahoo Query Language) to perform a cross domain ajax
I need to use the objdump and readelf commands in my application that runs
Opening a site economizing the data load I seem to run into a need
We need to create a script (ajax or php or javascript) that will clean
I need to provide a feature such that the user is able to upload
I'm working on a Facebook iFrame App and i need to use ajax request
I'm working on a Facebook iFrame App and i need to use ajax request
current i am trying to use ajax for my site ....... because of size

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.