Ö´ÐÐJSPºóÉú³ÉHTML¾²Ì¬Îļþ
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
public class toHtml extends HttpServlet {
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String url="";
String name="";
ServletContext sc = getServletContext();
//ÄãÒª·ÃÎʵÄjspÎļþ,Èçindex.jsp
//ÔòÄã·ÃÎÊÕâ¸öservletʱ¼Ó²ÎÊý.
//Èçhttp://localhost/toHtml?file_name=index
String file_name=request.getParameter("file_name");
//ÕâÊÇÄãÒªÉú³ÉHTMLµÄjspÎļþ,Èç
//http://localhost/index.jspµÄÖ´Ðнá¹û.
url = "/"+file_name+".jsp";
//ÕâÊÇÉú³ÉµÄhtmlÎļþÃû,Èçindex.htm.
name="/home/resin/resin-2.1.6/doc/"+file_name+".htm";
RequestDispatcher rd = sc.getRequestDispatcher(url);
final ByteArrayOutputStream os = new ByteArrayOutputStream();
final ServletOutputStream stream = new ServletOutputStream() {
public void write(byte[] data, int offset, int length) {
os.write(data, offset, length);
}
public void write(int b) throws IOException {
os.write(b);
}
};
final PrintWriter pw = new PrintWriter(new OutputStreamWriter(os));
HttpServletResponse rep = new HttpServletResponseWrapper(response) {
public ServletOutputStream getOutputStream() {
Ïà¹ØÎĵµ£º
HTMLÔªËØËÙ²é
ÏÂÃæÁгöÁË HTML ¶¨ÒåµÄÔªËØ¼¯£¬°´×Öĸ˳ÐòÅÅÁС£
±í1-1 ÔªËØÁбí
Ôª ËØ ˵ Ã÷
a ±íÃ÷³¬Á´½ÓµÄÆðʼ»òÄ¿µÄλÖÃ
acronym ±íÃ÷Ëõд´Ê
address ÌØ¶¨ÐÅÏ¢£¬ÈçµØÖ·¡¢Ç©Ãû¡¢×÷Õß¡¢´ËÎĵµµÄÔ´´
applet ÔÚÒ³ÃæÉÏ·ÅÖÿÉÖ´ÐÐÄÚÈÝ
area ¶¨Òå¿Í»§¶ËͼÏñÓ³ÉäÖÐÒ»¸ö³¬¼¶Á´½ÓÇøÓòµÄÐÎ×´¡¢×ø±ê
b Ö¸¶¨Îı¾Ó¦ÒÔ´ÖÌå ......
JSPµÄÖ¸ÁîÊÇÓÃÀ´°üº¬ÍⲿÎļþ»òÊǽøÐÐÒ³ÃæÈ«¾ÖÉèÖõģ»ËüµÄÓÐÈýÖÖ£¬·Ö±ðÊÇpage£¬include£¬taglibÖ¸Áî
1.pageÖ¸Áî
ÐÎÈç<%@page ÊôÐÔ='Öµ' ÊôÐÔ='Öµ' ........ %>
ÊôÐÔÓУº
language=''java'' £º É趨jspÒ³ÃæµÄ½Å±¾ÓïÑÔ£¬Ä¿Ç°Ö»Ö§³Öjava£¬Ä¬ÈÏÊÇjava
......
ÎÄÕÂÀàÐÍ:¼¼ÊõÎĵµ ¸üÐÂʱ¼ä:2009-03-03 ·¢²¼Õß:HIT-ASP ÎÄÕÂÀ´Ô´:HIT-ASP µã»÷´ÎÊý:550
Õª×Ô:
http://www.zzsky.cn/build/content/658.htm
http://www.blueidea.com/tech/multimedia/2 ......
ÎÒÃǶ¼ÖªµÀÔÚjspÖÐincludeÓÐÁ½ÖÖÐÎʽ,·Ö±ðÊÇ
<%@ include file=" "%>
<jsp:include page=" " flush="true"/>
ǰÕßÊÇÖ¸ÁîÔªËØ¡¢ºóÕßÊÇÐÐÎªÔªËØ.
ͨ³£µ±Ó¦ÓóÌÐòÖÐËùÓеÄÒ³ÃæµÄijЩ²¿·Ö(ÀýÈç±êÌâ¡¢Ò³½ÅºÍµ¼º½À¸)¶¼ÏàͬµÄʱºò,Î ......