import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class sthtml extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html;charset=GB2312");

		String fpath = this.getServletContext().getRealPath("/");// 获得服务器绝对路径

		String templateContent = null;

		FileInputStream fileinputstream = new FileInputStream(fpath + "mb.html");// 读取模板页,位于网站根目录
		int lenght = fileinputstream.available();
		byte bytes[] = new byte[lenght];
		fileinputstream.read(bytes);
		fileinputstream.close();
		templateContent = new String(bytes);

		templateContent = templateContent.replaceAll("#a#", "转换dewr1");
		templateContent = templateContent.replaceAll("#b#", "CC.;['");

		FileOutputStream fileoutputstream = new FileOutputStream(fpath
				+ "ok.html");
		byte tag_bytes[] = templateContent.getBytes();
		fileoutputstream.write(tag_bytes);
		fileoutputstream.close();
	}

}