Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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ÔªËØËÙ²é

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

JSPµÄÄÚÖöÔÏó

À´Ô´ÓÚ¡¶Java¡¢javaEEÈí¼þ¹¤³Ìʦ¾ÍÒµÇóÖ°Êֲᡷ
1 HttpServletRequestÀàµÄrequest¶ÔÏ󣺴ú±íÇëÇó¶ÔÏó£¬Ö÷ÒªÓÃÓÚ½ÓÊܿͻ§¶Ëͨ¹ýHTTPЭÒéÁ¬½Ó´«Êäµ½·þÎñÆ÷µÄÊý¾Ý¡£
2 HttpServletResponseÀàµÄresponse£º´ú±íÏìÓ¦¶ÔÏó£¬Ö÷ÒªÓÃÓÚÏò¿Í»§¶Ë·¢ËÍÊý¾Ý¡£
3 JspWriterÀàµÄout¶ÔÏó:Ö÷ÒªÓÃÓÚÏò¿Í»§¶ËÊä³öÊý¾Ý£¬OutµÄ»ùÀàÊÇJspWriter¡ ......

JSP¡¢Struts±ÜÃâFormÖØ¸´Ìá½»µÄ¼¸ÖÖ·½°¸

1 javascript £¬ÉèÖÃÒ»¸ö±äÁ¿£¬Ö»ÔÊÐíÌá½»Ò»´Î¡£



2 »¹ÊÇjavascript£¬½«Ìá½»°´Å¥»òÕßimageÖÃΪdisable

onsubmit="getElById('submitInput').disabled = true; return true;">


3 ÀûÓÃstrutsµÄͬ²½ÁîÅÆ»úÖÆ
......

JS»ñÈ¡ÍøÒ³ÖÐHTMLÔªËØµÄ¼¸ÖÖ·½·¨·ÖÎö

getElementById getElementsByName getElementsByTagName ´ó¸Å½éÉÜ
getElementById £¬        getElementsByName £¬getElementsByTagName
byidÖ»Êǵõ½µ¥¸ö¶ÔÏó ¡¡¡¡ºóÁ½¸öÊǵõ½¼¯ºÏ£¬
getElementById µÄÓ÷¨
<a id="link1" name="link1" href=http://homepage.yesky.com> ......

±ðÒÔΪǶÈëFlashµÄhtml²»ÖØÒª

ÎÄÕÂÀàÐÍ:¼¼ÊõÎĵµ   ¸üÐÂʱ¼ä:2009-03-03   ·¢²¼Õß:HIT-ASP   ÎÄÕÂÀ´Ô´:HIT-ASP   µã»÷´ÎÊý:550
   Õª×Ô: 
   http://www.zzsky.cn/build/content/658.htm  
   http://www.blueidea.com/tech/multimedia/2 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ