图像水印生成1
package text;
/**
* @author 让痛苦痛苦
* @parame 说明:建立起文件名映射关系后,ImageLoader Servlet会调用一个名为ImagerLabeler的组件。
* ImagerLoader负责设置参数,调用ImageLadeler生成水印,返回结果ServletOutputStream,最后以图象
* 的形式发送到浏览器。
*/
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.awt.*;
public class ImageLoader extends HttpServlet {
/**
* @author 让痛苦痛苦
* Initialize gload variables
*
*/
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
/**
* @author 让痛苦痛苦
* Proess the Http Get reques
*/
public void doGet(HttpServletRequest request,HttpServletResponse response) throws
ServletException,IOException
{
ServletOutputStream out=response.getOutputStream();
String varImage="";
try {
try {
varImage =request.getParameter("image");
} catch (Exception e) {
System.out.println("No parameter passed");
e.printStackTrace();
// TODO: handle exception
}
response.setContentType("image/jeg");//貌似可以改成jpg
//PropStore ps=new PropStore();
String imgFilename=null;
String strLoadImg="";
try {
File f=new File(strLoadImg);
strLoadImg=String.valueOf(f.getCanonicalPath()
+File.separator+"images"+File.separator+imgFilename);
} catch (IOException ioe) {
ioe.printStackTrace();
// TODO: handle exception
}
System.out.println("Look for /at:"+strLoadImg);
//ImageLabeler il=new ImageLabeler();
//out=il.PullImg(out,strLoadImg);
out.flush();
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
/**
*
* Clean u resources
*/
}
public void destroy()
{
}
/**
* @author 让痛苦痛苦
*
* @prama 说明:由于将处理任务留给了ImageLabeler,ImageLoader比较简洁,ImageLabeler还可以作为
* 独立程序来调试,这些特点都为成粗的开发带来便利.
*/
}