...
@Override
public void serveResource(ResourceRequest request, ResourceResponse response) {
String preferredStateImage = request.getParameter("preferredStateImage");
try {
String filename =
"/home/holdorph/projects/portal/apache-tomcat-6.0.32/webapps/CensusView-1.0/WEB-INF/images/"
+ preferredStateImage + ".jpg";
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();
}
}
...
|