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

Jsp±àÂë¹æ·¶


Jsp±àÂë¹æ·¶
1.1 Îļþºó׺(File Suffixes)
ÎļþÀà±ð ¡¡¡¡ ¡¡¡¡¡¡¡¡¡¡Îļþºó׺
--------------------------------------
JavaÔ´Îļþ¡¡¡¡¡¡¡¡¡¡¡¡¡¡.java
Java×Ö½ÚÂëÎļþ¡¡¡¡¡¡¡¡¡¡.class
¶¯Ì¬Ò³Ãæ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡.jsp
¾²Ì¬Ò³Ãæ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡.html
½Å±¾Îļþ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡.js
1.2 ³£ÓÃÎļþÃû(Common File Names)
ÎļþÃû ¡¡¡¡¡¡ ¡¡¡¡¡¡¡¡¡¡¡¡ ÓÃ;
------------------------------------------------
README¡¡¡¡¡¡¡¡¡¡¡¡ ¸ÅÊöÌض¨Ä¿Â¼ÏÂËùº¬ÄÚÈݵÄÎļþµÄÊ×Ñ¡ÎļþÃû
2 Ëõ½øÅÅ°æ(Indentation)
4¸ö¿Õ¸ñ³£±»×÷ΪËõ½øÅÅ°æµÄÒ»¸öµ¥Î»¡£Ëõ½øµÄÈ·ÇнâÊͲ¢Î´Ïêϸָ¶¨(¿Õ¸ñ vs. ÖƱí·û)¡£Ò»¸öÖƱí·ûµÈÓÚ8¸ö¿Õ¸ñ(¶ø·Ç4¸ö)¡£
3 ×¢ÊÍ(Comments)
Jsp³ÌÐòÓÐÁ½Àà×¢ÊÍ£º¾²Ì¬Ò³Ãæ×¢ÊͺÍJava×¢ÊÍ.
¾²Ì¬Ò³Ãæ×¢ÊÍ: <!— express -->
Jsp×¢ÊÍ: <%-- express --%>
4 JspÓï·¨(Syntax)
¢Ù JSP Element ¡¡¡¡¡¡¡¡
¢Ú Syntax ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¢Û Interpretation
---------------------------------------------------------------------------------------------
¢Ù JSP Expression
¢Ú <%= expression %>
¢Û Expression is evaluated and placed in output.
---------------------------------------------------------------------------------------------
¢Ù JSP Scriptlet
¢Ú <% code %>
¢Û Code is inserted in service method.
---------------------------------------------------------------------------------------------
¢Ù JSP Declaration
¢Ú <%! code %>
¢Û Code is inserted in body of servlet class, outside of service method.
---------------------------------------------------------------------------------------------
¢Ù JSP page Directive
¢Ú <%@ page att="val" %>
¢Û Directions to the servlet engine about eneral setup.
---------------------------------------------------------------------------------------------
¢Ù JSP include Directive
¢Ú <%@ include file="url" %>
¢Û A file on the local system to be included when the JSP page is translated into a servlet.
---------------------------------------------------------------------------------------------
¢Ù The


Ïà¹ØÎĵµ£º

jspµÇ¼ÑéÖ¤´úÂë


image.jspÓÃÓÚÉú³ÉÊý×ÖͼƬ
<%@ page contentType="image/jpeg;charset=gb2312" import="java.awt.*,
java.awt.image.*,java.util.*,javax.imageio.*" %>
<%!
Color getRandColor(int fc,int bc){//¸ø¶¨·¶Î§»ñµÃËæ»úÑÕÉ«
          Random random = new Rand ......

jsp ÖÐÎÄÂÒÂë½â¾ö´óÈ«

Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
¶þ¡¢±íµ¥Ìá½»ÖÐÎÄʱ³öÏÖÂÒÂë
Èý¡¢Êý¾Ý¿âÁ¬½Ó
´ó¼ÒÔÚJSPµÄ¿ª·¢¹ý³ÌÖУ¬¾­³£³öÏÖÖÐÎÄÂÒÂëµÄÎÊÌ⣬¿ÉÄÜÒ»ÖÁÀ§ÈÅ×ÅÄú£¬ÎÒÏÖÔÚ°ÑÎÒÔÚJSP¿ª·¢ÖÐÓöµ½
µÄÖÐÎÄÂÒÂëµÄÎÊÌâ¼°½â¾ö°ì·¨Ð´³öÀ´¹©´ó¼Ò²Î¿¼¡£
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
ÏÂÃæµÄÏÔʾҳÃæ(display.jsp)¾Í³öÏÖÂÒÂ룺
<html>
<head>
<tit ......

jsp×Ô¶¨Òå±êÇ©¿ª·¢

²»´¦ÀíÌåÄÚÈݵıêÇ©Àí½âÒ»ÏÂͼƬ1
´¦ÀíÌåÄÚÈݱêÇ©Àí½âÌáͼƬ2
1£ºJspWriter out = pageContext.getOut();
2£ºBodyContent bc = this.getBodyContent();
 3£ºString input = bc.getString();
 4£ºJspWriter out = bc.getEnclosingWriter();
²»´¦ÀíÌåÄÚÈÝ
µÚÒ»ÐдúÂëΪ²»´¦Àí±êÇ©ÌåÄÚÈÝʱÄõ½ÐèÒªµÄÊä³öµ½Ò³ ......

JSPʵÀý¶þ¡¢µÇ¼ÑéÖ¤

·½·¨Ò»¡¢
login.html
<html>
  <head>
    <title>Óû§µÇ¼</title>
    <meta http-equiv="content-type" content="text/html; charset=gb2312">
  </head>
 
  <script language="javascript">
  &nbs ......

JSP»·¾³ÅäÖÃ

Ò») °²×°JDK(jdk-1_5_0-windows-i586.exe)£¬Ä¬ÈÏ°²×°£»
(¶þ) °²×°Tomcat(tomcat5.5-installer.exe)£¬Ä¬ÈÏ°²×°£»
 * ˳Ðò²»¿ÉÒԵߵ¹ *
(Èý) ²âÊÔ°²×°½á¹û
1. ´ò¿ªä¯ÀÀÆ÷ÊäÈëhttp://localhost:8080£¬Èç¹û³É¹¦£¬Ôò»á¿´µ½»¶Ó­Ò³Ãæ¡£´Ëʱ·ÃÎʵÄ·¾¶Îª$tomcat/webapps/root/
(ËÄ) ½¨Á¢ÎÒµÄÕ¾µ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ