Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   jap proxy not work with images (http://www.go4expert.com/forums/jap-proxy-images-t26097/)

pcanoe 20Jun2011 19:01

jap proxy not work with images
 
Hello all.

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);
}
%>



All times are GMT +5.5. The time now is 18:39.