I would like to include an external website (e.g. http://www.example.com) in a div in my jsp page. I don’t want to use frames since it’s not advisable.
I tried searching online for a solution, but all what I found was including an internal webpage (e.g. webpage.jsp)…
I’ll really appreciate your help.
First of all, using frames is indeed not advisable if it concerns dividing/including local content (which is/was the most common abuse of frames). But it is definitely advisable if it concerns external content. For local content you should rather be using server-side includes such as
<jsp:include>.As to the concrete question, if the HTML response of the external website does not collide with the HTML response of your own JSP page (i.e. it does not return a complete
<html>document which would make your final HTML response completely invalid because of duplicate/nested<html>elements, but it returns some context-independent HTML fragment, e.g.<span>blah</span>), then you can use JSTL<c:import>for this.But if it returns a complete
<html>document and/or is context-dependent, then you really have to use<iframe>or to bring a proxy servlet in between. For a concrete kickoff example of such a servlet, check this answer: Make HttpURLConnection load web pages with images.