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 Displaying servlet content in a jsp including images Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Displaying servlet content in a jsp including images" Watch "Displaying servlet content in a jsp including images" New topic
Author

Displaying servlet content in a jsp including images

Avinash venna
Greenhorn

Joined: Jun 10, 2010
Posts: 17
Hello,

I have developed a servlet and it shows some reports (including images). Now I need to display the content of this servlet in a jsp and I am using <jsp:include page="/MyServlet"></jsp:include> to do so. I can see the full report if I run my servlet directly but when I run jsp, the images are missing. Please some one help me out in resolving this. Thanks in advance.

Regards,
Avinash V
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

why cant you move all display content to jsp rather than <jsp:include page="/MyServlet">? server is a controller, should not contain display/business logic in it directly.

and how you embedded images? show us the tag.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

The most likely cause of "broken" images is being sloppy with the URLs. See the JspFaq for information on properly addressing resources using server-relative URLs that begin weigh the context path.

And yes -- including servlet output in a JSP is a less-than-stellar practice.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Avinash venna
Greenhorn

Joined: Jun 10, 2010
Posts: 17
Actually I am connecting to a remote server and getting a java melody report and writing it to a servlet. Now, I need to display this report on a liferay portlet where I can display it in a jsp. So I am including the servlet in portlet's view.jsp
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying servlet content in a jsp including images