File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Include a servlet in a jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Include a servlet in a jsp" Watch "Include a servlet in a jsp" New topic
Author

Include a servlet in a jsp

matias casal
Ranch Hand

Joined: Oct 18, 2009
Posts: 61
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

Joined: Feb 14, 2001
Posts: 71
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

Joined: Jan 10, 2002
Posts: 60997
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
matias casal
Ranch Hand

Joined: Oct 18, 2009
Posts: 61
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

Joined: Feb 14, 2001
Posts: 71
Maybe the answer is too obvious . Instead of output like:



the servlet needs to generate output like:

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60997
    
  65

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

Joined: Oct 18, 2009
Posts: 61
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

Joined: Oct 18, 2009
Posts: 61
The html source is the following
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Include a servlet in a jsp