Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Code Block
java
java
titleCensusViewPortlet.java
...
	@Override
	public void serveResource(ResourceRequest request, ResourceResponse response) {
		String preferredStateImage = request.getParameter(PREFERRED_STATE);
		try {
			String filename =
				"/home/holdorph/pluto-2projects/portal/apache-tomcat-6.0.032/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();
		}
	}
...

...