I have been trying the following code to download any
image from the internet given the url as a parameter.
However, this code is not working. It gust gives me a
blank page.
public void doPost(HttpServletRequest req,
HttpServletResponse res) throws IOException,
ServletException
{
//Setting Content Type and Size for Response
res.setContentType(req.getContentType());
res.setContentLength(req.getContentLength());
//Declaring Input and Output Streams
URL url = new URL(req.getParameter("url"));
InputStream in =
url.openConnection().getInputStream();
ServletOutputStream out = res.getOutputStream();
//Reading data from in and printing to out
int data;
while((data = in.read()) != -1)
out.write(data);
//Closing Streams
in.close();
out.flush();
out.close();
}
Can any body please, tell me whats wrong with this
code...
Regards,,
__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html