Java servlet allows you to scale images. So this component could be used for creating image preview (thumbnail) on the fly. Also you can show small images on the mobile sites for example. How to use it: a) copy imagescalePackage.jar into WEB-INF/lib directory b) describe Image scale servlet in your web.xml file. You can provide the following optional parameters: dir - describes a directory for your image files
For example:
<servlet> <servlet-name>ImageScale</servlet-name> <servlet-class>com.jsos.image.ImageScaleServlet</servlet-class> <init-param> <param-name>dir</param-name> <param-value>c:/orion/default-web-app/images</param-value> </init-param> <init-param> <param-name>width</param-name> <param-value>125</param-value> </init-param> </servlet> You can provide both width and height or just one of them. In this case the second dimension will be changed accordingly. c) describe a mapping for this servlet in web.xml file
<servlet-mapping> <servlet-name>ImageScale</servlet-name> <url-pattern>/servlet/ImageScale</url-pattern> </servlet-mapping> and now you can use servlet in this form: http://your_host/servlet/ImageScale?image_file. E.g.:
<img border="0" alt="Preview" src="http://host/servlet/ImageScale?bigfile.jpg"/> and by the same way you can scale and display images located anywhere - just provide an URL for the image:
<img border="0" alt="Preview" src="http://host/servlet/ImageScale?http://server/bigfile.jpg"/> for downloading: servlet: imagescalePackage.jar © Coldbeans Software Comments? See also JSOS - the largest collection of servlets and filters.
|
Also in Coldtags:
|