Hi
I have an action class that serves us images from my application. The java
class is
fairly simple and mostly copied from (our friend) the wiki:
public class Image extends Action {
/** Creates a new instance of Image */
public Image() {
super();
}
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse
response) {
String name = null;
try {
name = request.getParameter("sin");
if (name == null || name.length() == 0)
return null;
File f = new File(Focus.getImageDirectory() + "/" + name);
if (f.exists()) {
response.setContentLength((int) f.length());
response.setContentType("application/x-file-download");
response.setHeader("Content-disposition", "attachment;
filename=" + name );
FileInputStream fis = new FileInputStream(f);
ServletOutputStream sos = response.getOutputStream();
byte[] buffer = new byte[32768];
int n = 0;
while ((n = fis.read(buffer)) != -1)
sos.write(buffer, 0, n);
fis.close();
sos.flush();
}
} catch (Exception e) {
System.err.println(">> Error serving image, probably invalid type:
" + name);
TableDoc td = new TableDoc();
td.setDownload(name);
td.close();
}
return null;
}
}
However when this class runs I get the following exception:
NotifyUtil::java.net.SocketException: Software caused connection abort: recv
failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:222)
at java.io.BufferedInputStream.read(BufferedInputStream.java:277)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:760)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:711)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:725)
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.jav
a:635)
at
org.netbeans.modules.web.monitor.server.NotifyUtil$RecordSender.run(NotifyUtil.java:
248)
As I'm not utilising a SocketInputStream I'm confused why I would be getting
this error.
Can anybody help?
Kind regards
mc
FOCUS Computing
Mob: 0415 24 26 24
[EMAIL PROTECTED]
http://www.focus-computing.com.au
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.13/124 - Release Date: 7/10/2005
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]