Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Include a servlet in a jsp

 
matias casal
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have the following problem.
I am trying to include in a div, the content shown by a servlet. I used to include my servlet in an iframe.

But now, I need to use divs, no more iframes.
I tried this:


The servlets was executed, but it was not shown on the jsp

Thanks!
 
Kris Schneider
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say, "it was not shown on the jsp", do you mean that the output you expected wasn't visible or that it really wasn't included in the response? Did you view the source of the response in a browser? Perhaps there's just a problem with your HTML...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the servlet generating? Are you sure it's valid HTML?

When the servlet was sending HTML to the iframe was it a full HTML page? if so, did you modify it to send a fragment? You can't just stick a full HTML page inside another HTML page.
 
matias casal
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The servlet creates a html page in temp folder.
I used to use the iframe because it was the only way i found to put the reports in a jsp, but my boss suggested me to use divs, no more iframes.
Any idea?
 
Kris Schneider
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe the answer is too obvious . Instead of output like:



the servlet needs to generate output like:

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't answer my question. Is what is being sent to the browser valid HTML? If you are including a page with an <html> tag inside a <div>, that is not valid!

Do a View Source at the browser. Is the HTML page valid?
 
matias casal
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The browser recieves <html><body>...</body></html>

Are you sure thats the error?

I tested

and abc.jsp is
and it works.
Thank you anyway

 
matias casal
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The html source is the following
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic