//jai_codec-1.1.3-alpha.jar
import java.awt.image.RenderedImage;
import java.io.File;
import com.sun.media.jai.codec.FileSeekableStream;
import com.sun.media.jai.codec.ImageCodec;
import com.sun.media.jai.codec.ImageDecoder;
import com.sun.media.jai.codec.SeekableStream;
import com.sun.media.jai.codec.TIFFDecodeParam;
import javax.media.jai.JAI;
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
Integer index = new Integer(request.getParameter("index"));
System.out.println(request.getContextPath());
System.out.println(request.getPathInfo());
System.out.println(request.getRealPath("/"));
File file = new File(request.getRealPath("/") + "/example/tiff/example.tif");
SeekableStream s = new FileSeekableStream(file);
ImageDecoder dec = ImageCodec.createImageDecoder("tiff", s, null);
RenderedImage temp = dec.decodeAsRenderedImage(index);
System.out.println("Width:" + temp.getWidth() + ",Height:" + temp.getHeight());
JAI.create("encode", temp, response.getOutputStream(), "JPEG", null);
return null;