Is there anyway ( API or something ) to include external page or url in to JSP.
I found a import tag in JTSL core tag libaray, because of web server ( IWS 6 sp5 ) I cannot use.
I would appreciate if you if there is anyway to do it. For reference see <c:import url="http://www.yahoo.com" />
Thanks
-
External Page include (2 messages)
- Posted by: Nagsen Chankapure
- Posted on: August 28 2003 15:42 EDT
Threaded Messages (2)
- External Page include by Paul Strack on August 28 2003 16:27 EDT
- External Page include by Nagsen Chankapure on August 29 2003 11:14 EDT
-
External Page include[ Go to top ]
- Posted by: Paul Strack
- Posted on: August 28 2003 16:27 EDT
- in response to Nagsen Chankapure
The Jakarta IO taglib also performs these kinds of operations:
<io:http url="http://www.yahoo.com"/>
You can get it at:
http://jakarta.apache.org/taglibs/doc/io-doc/intro.html
Or, you can do the same thing scriptlets using the java.net.URL and java.net.URLConnection classes:
<%
URL url = new URL("http://www.yahoo.com");
URLConnection con = url.openConnection();
con.connect();
InputStream is = (InputStream) con.getContent();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line = br.readLine();
while (line != null) {
out.println(line);
line = br.readLine();
}
br.close();
%>
Better yet, write a utility method to do the above.
public void printURLcontents (String urlString, JspWriter out) {
URL url = new URL(urlString);
URLConnection con = url.openConnection();
con.connect();
InputStream is = (InputStream) con.getContent();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line = br.readLine();
while (line != null) {
out.println(line);
line = br.readLine();
}
br.close();
}
Proper error-handling is left as an exercise to the reader. -
External Page include[ Go to top ]
- Posted by: Nagsen Chankapure
- Posted on: August 29 2003 11:14 EDT
- in response to Paul Strack
Thanks Paul... Good recommendation !!