Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Ö´ÐÐ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 radioÅжÏ

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta NAME="Copyright" CONTENT="Copyright (c) 2009 LOADCOM Corporation. All Rights Reserved."> ......

HTMLÔªËØËÙ²é

HTMLÔªËØËÙ²é
ÏÂÃæÁгöÁË HTML ¶¨ÒåµÄÔªËØ¼¯£¬°´×Öĸ˳ÐòÅÅÁС£
±í1-1 ÔªËØÁбí
Ôª ËØ ˵ Ã÷
a ±íÃ÷³¬Á´½ÓµÄÆðʼ»òÄ¿µÄλÖÃ
acronym ±íÃ÷Ëõд´Ê
address ÌØ¶¨ÐÅÏ¢£¬ÈçµØÖ·¡¢Ç©Ãû¡¢×÷Õß¡¢´ËÎĵµµÄÔ­´´
applet ÔÚÒ³ÃæÉÏ·ÅÖÿÉÖ´ÐÐÄÚÈÝ
area ¶¨Òå¿Í»§¶ËͼÏñÓ³ÉäÖÐÒ»¸ö³¬¼¶Á´½ÓÇøÓòµÄÐÎ×´¡¢×ø±ê
b Ö¸¶¨Îı¾Ó¦ÒÔ´ÖÌå ......

ÎÒµÄJSPѧϰ±Ê¼Ç JSPÒ³ÃæÖеÄ×¢ÊÍ

JSPÒ³ÃæÖÐÒ»°ãÓÐÁ½Àà×¢ÊÍ
1.html×¢ÊÍ
ÐÎÈç<!--...................-->
Ëü»áͬhtml±ê¼Çһͬ·¢µ½¿Í»§¶Ë
2.jsp×¢ÊÍ£¨3ÖÖ£©
ÐÎÈç<%--.............................--%>
Ëü²»»á±»·¢Ë͵½¿Í»§¶Ë£¬Ö»ÓÃÀ´×¢ÊÍ·þÎñÆ÷¶ËµÄjspÎļþ£¬Á¬jspÉú³ÉµÄservletҲûÓÐ×¢ÊͽøÈ¥£¬ÕâÒ²ÊǴ󲿷ÖÈËʹÓõÄ×¢ÊÍ
ÐÎÈç<%//...... ......

HTMLµÄµß¸²ÕßHTWL£¨Î¬ÓïÑÔ£©

      ´´Ð£¬ÔƼÆË㣬web2.0£¬»¹¼«ÓпÉÄÜweb3.0¡¢web4.0...ÇëÞÑÐÄ×ÔÎÊ£¬Óд´ÐÂÂð£¿IT¹»»ìÂÒÂð£¿Ò²ÐíÓÐЩÈ˲»³ÐÈÏ£¬ËûÃÇÖ»»á˵ÄÇЩÊÇ×îÏȽøµÄ¼¼Êõ¡£ÕæµÄÈç´Ë£¿ÕæÊµµÄÇé¿öÊÇËûÃÇÏë½ÁÂÒÕâ¸öÊÀ½ç£¬³Ã»ëË®ÃþÓ㣬Ҳ¾ÍÊÇÏëÂÒÊÀ³öÓ¢ÐÛ¶øÒÑ¡£
      ºÜ¶àÈËÓ¦¸ÃÖªµÀ£¬webÓ¦ÓõÄÄÇ ......

JSPÖж¯Ì¬INCLUDEÓ뾲̬INCLUDEµÄÇø±ð

ÎÒÃǶ¼ÖªµÀÔÚjspÖÐincludeÓÐÁ½ÖÖÐÎʽ,·Ö±ðÊÇ
    <%@ include file=" "%>
    <jsp:include page=" " flush="true"/>
    ǰÕßÊÇÖ¸ÁîÔªËØ¡¢ºóÕßÊÇÐÐÎªÔªËØ.
    ͨ³£µ±Ó¦ÓóÌÐòÖÐËùÓеÄÒ³ÃæµÄijЩ²¿·Ö(ÀýÈç±êÌâ¡¢Ò³½ÅºÍµ¼º½À¸)¶¼ÏàͬµÄʱºò,Î ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ