...
@Override
public void serveResource(ResourceRequest request, ResourceResponse response) {
String preferredStateImage = request.getParameter(PREFERRED_STATE_IMAGE);
try {
String filename =
"/home/holdorph/pluto-2.0.0/webapps/CensusView-1.0/WEB-INF/images/"
+ preferredStateImage + ".jpg";
http://www.ja-sig.org/wiki/pages/editpage.action?pageId=29131898#
if ((preferredStateImage != null)
&& (preferredStateImage.length() > 0)) {
response.setContentType(getPortletContext().getMimeType(
filename));
OutputStream os = response.getPortletOutputStream();
byte b[] = new byte[1024];
InputStream is = new FileInputStream(filename);
int numRead = 0;
while ((numRead = is.read(b)) > 0) {
os.write(b, 0, numRead);
}
os.flush();
} else {
System.err.println("ERROR! No Preferred State Image detected.");
}
} catch (IOException e) {
e.printStackTrace();
}
}
...
|