イメージ表示
Servletを作成しなくても、OutputStreamに画像のバイト情報を出力すればよいので下記でいけるのでは。
<html xmlns:m="http://www.seasar.org/maya"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Image test</title> </head> <body> ImageTest<br/> <img m:src="#{test.image}" /> </body> </html>
testコンポーネントには、getImageがあればOKかな!?
追記
public String getImage() { FacesContext context = FacesContext.getCurrentInstance(); HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse(); response.setContentType("image/jpeg"); int data; try { FileInputStream in = new FileInputStream("/tmp/test.jpeg"); ServletOutputStream out = response.getOutputStream(); while ((data = in.read()) != -1) { out.write(data); } } catch (Exception e) { e.printStackTrace(); } context.responseComplete(); return null; }
で画像が表示されてOKと思ったが画面自体が画像になってしまうから、やはりweb.xmlで画像用サーブレットをマッピングする必要があるのか...
追記よくよく動きを考えてみたら...
imgタグなどは、HTMLにレンダリングされて初めてブラウザがHTTPリクエストを投げるわけだから
上記方法を取るとすれば、画像部分をIFRAMEにするなどトリッキーな事をする必要がありそう。
やはりサーブレットを用意するのが現実解。
画像取得用のサーブレットをS2JSFやTeedaで提供するというのはアリだと思います。
追記
MyFacesのsandboxにはgraphicImageDynamicがあります。