jspÉú³Éhtml¾²Ì¬Ò³Ãæ´úÂë
<%@ page contentType="text/html;charset=GBK"%>
<%@page import="java.util.*"%>
<%@page import="java.io.*" %>
<%
//ÔÚÕâÀïÈç¹ûд³É“WEB-INF\templates\template.htm”³ÌÐò»á±¨´í
String filePath = request.getRealPath("/")+"WEB-INF/templates/template.htm";
out.print(filePath);
String templateContent="";
FileInputStream fileinputstream = new FileInputStream(filePath);//¶Áȡģ¿éÎļþ
//int lenght = fileinputstream.available();
byte bytes[] = new byte[1024];
fileinputstream.read(bytes);
fileinputstream.close();
templateContent = new String(bytes);
out.print("ÒÔÏÂÊÇÄ£°åÄÚÈÝ£º<br>"+templateContent+"<br> ÒÔÏÂÊÇÖû»ÒÔºóµÄhtmlÄÚÈÝ<br><hr>");
templateContent=templateContent.replaceAll("#title#","ÎÄÕ±êÌâ");
templateContent=templateContent.replaceAll("#author#","×÷ÕßÊÇË");//Ìæ»»µôÄ£¿éÖÐÏàÓ¦µÄµØ·½
templateContent=templateContent.replaceAll("#content#","ÎÄÕÂÄÚÈÝ");
// ¸ù¾Ýʱ¼äµÃÎļþÃû
Calendar calendar = Calendar.getInstance();
String fileame = String.valueOf(calendar.getTimeInMillis()) +".html";
fileame = request.getRealPath("/")+fileame;//Éú³ÉµÄhtmlÎļþ±£´æÂ·¾¶
out.print(templateContent);
FileOutputStream fileoutputstream = new FileOutputStream(fileame);//½¨Á¢ÎļþÊä³öÁ÷
byte tag_bytes[] = templateContent.getBytes();
fileoutputstream.write(tag_bytes);
fileoutputstream.close();
%>
Ïà¹ØÎĵµ£º
JSP×Ô¶¨Òå±êÇ©
Ò»£¬ »ù±¾¸ÅÄ
±êÇ©(Tag):±êÇ©ÊÇÒ»ÖÖXMLÔªËØ£¬Í¨¹ý±êÇ©¿ÉÒÔʹJSPÍøÒ³±äµÃ¼ò½àÒ×ÓÚά»¤£¬»¹¿ÉÒÔ·½±ãµØÊµÏÖͬһ¸öJSPÎļþÖ§³Ö¶àÖÖÓïÑÔ°æ±¾¡£ÓÉÓÚ±êÇ©ÊÇXMLÔªËØ£¬ËùÒÔËüµÄÃû³ÆºÍÊôÐÔ¶¼ÊÇ´óСдÃô¸ÐµÄ¡£
±êÇ©¿â(Tag library)£ºÓÉһϵÁй¦ÄÜÏàËÆ£¬Âß¼ÉÏ»¥ÏàÁªÏµµÄ±êÇ©¹¹³ÉµÄ¼¯ºÏ³ÆÎª±êÇ©¿ ......
public class TaskBean extends Thread{
public TaskBean(){
}
private int percent=0;
private boolean complete=false;
public synchronized&nb ......
HTTP ͨÐÅÐÒéÊǿͻ§Óë·þÎñÆ÷Ö®¼äÒ»ÖÖÌá½»£¨ÇëÇó£© ÐÅÏ¢ÓëÏìÓ¦ÐÅÏ¢
£¨request/respone£©µÄͨÐÅÐÒé¡£ÔÚJSP ÖУ¬ÄÚÖöÔÏórequest ·â×°ÁËÓû§Ìá½»µÄÐÅÏ¢£¬
ÄÇô¸Ã¶ÔÏóµ÷ÓÃÏàÓ¦µÄ·½·¨¿ÉÒÔ»ñÈ¡·â×°µÄÐÅÏ¢£¬¼´Ê¹ÓøöÔÏó¿ÉÒÔ»ñÈ¡Óû§Ìá½»µÄÐÅ
Ï¢¡£
¿Í»§Í¨³£Ê¹ÓÃHTML ±íµ¥Ïò·þÎñÆ÷µÄij¸öJSP Ò³ÃæÌá½»ÐÅÏ¢£¬±íµ¥µÄÒ»°ã¸ñʽÊÇ£º ......
HTML ×¢ÊÍ
ÔÚ¿Í»§¶ËÏÔʾһ¸ö×¢ÊÍ.
JSP Óï·¨
<!-- comment [ <%= expression %> ] -->
Àý×Ó 1
<!-- This file displays the user login screen -->
ÔÚ¿Í»§¶ËµÄHTMLÔ´´úÂëÖвúÉúºÍÉÏÃæÒ»ÑùµÄÊý¾Ý£º
<!-- This file displays the user login screen -->
Àý×Ó 2
<!-- This page was ......