I have a problem.
This is a proxy in jsp. It takes an url change it and recall it. It works with html file but not images. How can I make it work for images.
Thank for all
Cheers.
Code:
<%@page session="false"%>
<%@page import="java.net.*,java.io.*" %>
<%
try {
if (request.getParameter("img") != null) {
String strImage = request.getParameter("img");
String strURL = "a link in http";
URL urlRequest = new URL(strURL);
HttpURLConnection httpConnection = (HttpURLConnection)urlRequest.openConnection();
httpConnection.setDoOutput(true);
httpConnection.setRequestMethod(request.getMethod());
int clength = request.getContentLength();
if(clength > 0) {
httpConnection.setDoInput(true);
byte[] idata = newbyte[clength];
request.getInputStream().read(idata, 0, clength);
httpConnection.getOutputStream().write(idata, 0, clength);
}
response.setContentType(httpConnection.getContentType());
BufferedReader rd = new BufferedReader(new InputStreamReader(httpConnection.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
out.println(line);
}
rd.close();
}
}catch(Exception e) {
response.setStatus(500);
}
%>
