richardchaven said:
I want to be able to deploy a minimum of files (ideally one) without
configuring anything. If I can use a jsp to get data from a different
page, that will be the simpliest.
I've seens a reference to a custom tag library that allows one to, for
instance, embed a quote from a different site in a JSP, so it seems
like this is theoretically possible.
Any ideas ?
Try and take the body of servlet code below and copy
into a <% %> block in your JSP page.
But I warn you. You can easily get problems
with content type and blank lines when doing
what is servlet work in a JSP page.
Arne
================================================
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.net.*;
public class CopyServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
try {
URL url = new URL("
http://www.foobar.dk/");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.connect();
if(con.getResponseCode() == HttpURLConnection.HTTP_OK) {
InputStream is = con.getInputStream();
byte[] b = new byte[1000];
int n;
while((n = is.read(b)) >= 0) {
String s = new String(b,0,n);
response.getOutputStream().println(s);
}
is.close();
}
con.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}