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 8959953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:33:44+00:00 2026-06-15T15:33:44+00:00

I pose a problem that is making me lose my mind. I need to

  • 0

I pose a problem that is making me lose my mind.
I need to develope a servlet for cobrowsing, whose logic is:
a “master” type an address in the addressbar, and a POST method (a form) sends this information to the servlet.

The servlet through the object HttpGet retrieves the requested resource and adds a tag to solve any problems due to relative links.

the returned resource is then displayed in an IFRAME (the form of the search bar had as target the iframe)

When I click on any link on the page within the iframe the action of the link, with jquery, is prevented (event.prevent()) and in its place will be sent a POST that updates the page displayed in the iframe.

the update works and the servlet does its job properly, in fact the POST response contains the html of the page requested.

Now the problem: how do I display it in the iframe?

I tried with:

$('.myIframe').contents().load("myServlet", {someParameters}); 

and with:

$.post("myServlet", {someParameters}).success(function(data) {
$(".myIframe").contents().html(data);});

but in both cases i receive correct response (the html) but the iframe is empty.
Moreover, in these cases, the browser can not resolve relative links (with firebug the resource requirements referenced with relative links are not met, and receive a 404 response), although the first call (the addressbar) the work.

Any idea?

P.S. sorry for my English!

the HTML code is:

<div id="searchbar">
<form action="myServlet" target="navigation" name="form" method="POST">
<input type="text" name="goTo" id="addressbar">
</form></div>
<div id="iframe"><iframe class="myIframe" scrolling="no" name="navigation"></iframe>

and, when iframe is loaded, each click on a link is recognized by:

$('.myIframe').load(function() {
   $('.myIframe').contents().find('a').click(function(event) {  
      $('html', $('.myIframe').contents()).load("myServlet", {someParameters});
   });
}); 

the type of data obtained in the post response is a typical web resources (the same you would get browsing outside the servlet cobrowsing – html, asp, php, etc.)

@Yevgeniy: Hi, it works, but now, when loading a page in this way, is not enabled the event of recognition of the click on a link (iframe load() event not fired?)

some updates
I separated the action of POST (which updates the session cobrowsing) by GET (instead asynchronously retrieves the resource session and should show iframe)

POST side is ok,

asynchronous GET is implemented using AsyncContext and this JS (oracle tutorial):

var messagesWaiting = false;          
function getMessages(){
    if(!messagesWaiting){
        messagesWaiting = true;
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange=function(){
            if (xmlhttp.readyState==4 && xmlhttp.status==200) {
                messagesWaiting = false;
                var iframe = $(".browser")[0].contentWindow.document;
                iframe.open();
                iframe.write(xmlhttp.responseText);
                iframe.close();
            } 
        }
        xmlhttp.open("GET", "CoBroServlet?t="+new Date()+"&type=UPDATE&sharedSessionId="+ document.getElementById("ssid").innerHTML, true);
    xmlhttp.send();
    }
}
setInterval(getMessages, 1000);

the strange thing is that in some cases it works fine, but in other cases the entire contents of a GET containing the remote resource is printed “raw” on the screen (it is not put into #document nested in iframe but between )

to explain better:
Sometimes (always to the first search in addressbar) firebug shows that the content of the iframe is the expected one.
Browsing the site through iframe interaction with the servlet and outputs are ok.

Suddenly (doing a new search in addressbar) the iframe prints the contents of the GET response.

From this time also repeating the search in addressbar of the first site (the one that worked well) is printed to the screen the raw html of the page.

I also tried to clear the iframe every new cycle of getMessages function () with $ (‘. MyIframe). Empty (), but I do not get anything different!

  • 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-06-15T15:33:46+00:00Added an answer on June 15, 2026 at 3:33 pm

    I solved it by passing parameters encoded as path of the request, simply going to replace the src attribute of the iframe:

    $(".myIframe").attr('src', "myServlet/"+encodedParam);
    

    thanks to all

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

Sidebar

Related Questions

I have three classes that pose a problem when trying to add a new
I have a home-screen widget that has an icon that starts/so pose to bring
Sorry if this is a dup; I haven't found any questions that pose quite
I'm soon to be working on a project that poses a problem for me.
I have a legacy (solve this problem for us issue) app that communicates with
To make my question more concrete, let me pose it as a problem: situation
I have posts and attachments. The source of my problem is that I would
This is a followup to this question . Since the problem that I'm now
Here is my problem. I need to implement a multi target decision tree algorithm.
I'd like to pose a few abstract questions about computer vision research. I haven't

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.