Java °æ (¾«»ªÇø)
·¢ÐÅÈË: bali (°¢±¼), ÐÅÇø: Java
±ê Ìâ: ÅúÅÐÐԵؿ´´ýÒ»ÖÖ¿ÉÐеıíʾ¼¼Êõ£º JavaServerPages
·¢ÐÅÕ¾: ¹þ¹¤´ó×϶¡Ïã (2000Äê12ÔÂ30ÈÕ01:06:45 ÐÇÆÚÁù), תÐÅ
JSP ¼¼Êõ -- ÊÇÓÑ»¹ÊǵУ¿
ÅúÅÐÐԵؿ´´ýÒ»ÖÖ¿ÉÐеıíʾ¼¼Êõ£º JavaServerPages servlet ¼¼Êõ
Brett McLaughlin
Lutris Technologies ¹«Ë¾µÄ Enhydra Õ½ÂÔ¼Ò
2000 Äê 10 ÔÂ
ÄÚÈÝ£º
ÀúÊ·µãµÎ
Ç°Ìá
¸ôÀëÓ뼯³É
±àдÓëÐÞ¸Ä
JSP µÄ³Ðŵ
ÄÚÈÝÓë±íʾ
Éè¼ÆÈËÔ±Ó뿪·¢ÈËÔ±
ÎÊÌâ
µ¥Ò»´¦ÀíÓë¶àÈÎÎñ
С½á
²Î¿¼×ÊÁÏ
×÷Õß¼ò½é
×÷ΪһÃû Java ¼¼ÊõÀÏÊÖºÍÐ嵀 Enhydra Óµ»¤Õߣ¬×÷ÕßÁ¦È°¿ª·¢ÈËÔ±ÔÚÑ¡ÔñÉè¼Æ Web Ó¦ÓóÌÐòµÄ;¾¶Ê±£¬¿¼ÂÇһϠJavaServerPages (JSP) servlet ÒÔÍâµÄÆäËû·½·¨¡£JSP ¼¼ÊõÊÇ Sun ¹«Ë¾µÄ J2EE
ƽ̨ºÍ±à³ÌÄ£Ð͵ÄÒ»²¿·Ö£¬ÊÇΪ½â¾öÈçºÎ°Ñµ¥µ÷µÄÄÚÈݱä³ÉÒýÈËעĿµÄ±íʾ²ãÕâÒ»ÄÑÌâ¶øÌá³öµÄ½â¾ö·½°¸¡£Êµ¼ÊÉÏ£¬Web ¿ª·¢ÈËÔ±Ò²²¢·ÇÒ»ÖÂ¶Ô JSP ¼¼Êõ±íʾÂúÒâ¡£¼ÈÈ»ÏÖÔÚÓÐ Sun ¼¼ÊõµÄ¶àÖÖ±äÌå¿ÉÒÔʹÓã¬ËùÒÔÄú¿ÉÒÔÔÚÐí¶à±íʾ¼¼ÊõÖ®¼ä½øÐÐÑ¡Ôñ¡£±¾ÎÄÉîÈë̽ÌÖ JSP
±àÂë¼¼Êõ£¬²¢Ì½¾¿¼¸¸öÓÐÎüÒýÁ¦µÄÌæ´ú·½·¨¡£
±íʾ¼¼ÊõÉè¼ÆÓÃÀ´½«Æ½µµÄÀ¶¡ÎÄÔʼ Web ÄÚÈÝת»¯Îª°ü×°ÔÚÓÐÎüÒýÁ¦µÄ±íʾ²ãÖеÄÄÚÈÝ¡£JavaServer Pages (JSP) ¼¼Êõ£¬×÷Ϊ Sun ¹«Ë¾µÄ±íʾģÐÍºÍ J2EE ƽ̨µÄÒ»²¿·Ö£¬Êܵ½Á˼«´ó¹Ø×¢¡£Ê¹Óà JSP ¼¼ÊõÓÐÀûÓбף¬Web ¿ª·¢ÈËÔ±Ó¦ÖªÏþÕâЩÀû±× --
¶®µÃËûÃDz»±Ø¾ÐÄàÓÚÕâÒ»¼¼Êõ¡£Êµ¼ÊÉÏ£¬½üÀ´³öÏÖÁËÐí¶à±íʾ¼¼Êõ¡£±¾ÎÄÒÔ±íʾ¼¼ÊõËùÒª½â¾öµÄÎÊÌâΪ¿ª¶Ë£¬È»ºó¿¼²ì JSP Ä£Ð͵ÄÌØÓÐÓÅÊƺÍÈõµã¡£×îºó£¬½éÉܼ¸¸ö¿ÉÒÔ´úÌæ Sun µÄ±íʾ¼¼ÊõµÄ¿ÉÐз½°¸¡£
ÀúÊ·µãµÎ
ÔÚÉîÈë½âÊͱíʾ¼¼Êõ֮ǰ£¬½éÉÜһЩµ¼Ö´˼¼Êõ²úÉúµÄÏêϸ±³¾°×ÊÁϺÜÓаïÖú¡£½ö½öÔÚ 10 ÄêÇ°£¬ÊÝ¿Í»§»ú»¹ÊÇÒ»¸öºÜеÄÊõÓï¡£ÄÇʱÎÒÃÇ»¹Éú»îÔŲ́ʽ»úÓ¦ÓóÌÐòµÄÊÀ½çÖУ¬Ê¹Óõͼ¶µÄ 286 ΢´¦ÀíÆ÷£¬ÃÐ×ÅÑÛ¾¦¿´ 14
Ó¢´çµÄÏÔʾÆ÷¡£µ«ÊÇÏÖÔÚʱ´ú²»Í¬ÁË£¬ÅóÓÑ£¡ÏÖÔÚ£¬ÎÒµĄ̈ʽ»ú³ýÁËÔËÐÐ Web ä¯ÀÀÆ÷Ö®ÍâʲôҲ²»¸É¡£ÎÒÃÇʹÓà Sun¡¢IBM¡¢HP¡¢Compaq ºÍÆäËû¹«Ë¾µÄ·þÎñÆ÷À´ÔËÐмÆËã¡¢ÒµÎñÂß¼ºÍÄÚÈÝ¡£ÄǸöСÏÔʾÆ÷ÄØ£¿ËüÒѱ»ÓÖ´óÓÖƯÁÁµÄ 21 Ó¢´çºÍ 25
Ó¢´çµÈÀë×ÓÌåƽÃæÏÔʾÆ÷ËùÈ¡´ú¡£ÎªÊ²Ã´ÄØ£¿ÒòΪÕâÑùÎÒÃǾͿÉÒÔ¹Û¿´´í×Û¸´Ô HTML ÏÔʾ£¬¶øÕâЩ HTML
ÏÔʾÊÇÇ¿´óµÄÓ¦ÓóÌÐòµÄÇ°¶Ë¡£µ¥µ÷³ÁÃƵĽçÃæÒѲ»ÄÜÂú×ãÒªÇó£»ÏÖÔÚ£¬ÎÒÃÇÏ£Íû¿´µ½»ªÀöµÄͼÐΡ¢Òƶ¯µÄͼÏñ¡¢É«²Êе÷µÄ±íʾ£¬²»¹ÜÄĸö·¿¼ä¿´ÉÏÈ¥¶¼ÄÇôƯÁÁ£¬²¢ÇÒÄܹ»¿ìËÙÏÔʾ³öÀ´¡£
Ç°Ìá
Ê®ÄêºóµÄ½ñÌ죬×÷Ϊ³ûÐ뵀 Windows Ó¦ÓóÌÐòÒѾ³ÉΪÀúÊ·£¬ÎÒÃÇÈÔÃæÁÙ×űíʾ·½·¨Éϵľ޴óת±ä¡£±¯²ÒµÄ Visual Basic ºÍ C ³ÌÐòÔ±·¢ÏÖ£¬ËûÃÇÏÖÔÚÖ»Äܱàдºó¶Ëϵͳ»ò½öÓÃÓÚ Windows µÄÓ¦ÓóÌÐò£¬»òÕßÒÑÔÚ×Ô¼ºµÄ¹¤¾ßÏäÖÐÌí¼ÓÁËÄÜÌṩ Web ¹¦ÄܵÄÓïÑÔ£¬ÀýÈç Java
ÓïÑÔ¡£²»Ö§³ÖËÄ·ÖÖ®ÈýÒÔÉÏ ML ÓïÑÔ£¨Èç HTML¡¢XML ºÍ WML£©µÄÓ¦ÓóÌÐò¼´Ê¹²»±»ÈÏΪÊÇÍêȫʧ°ÜµÄ£¬Ò²»á±»ÈÏΪÊǺܵÍÁӵġ£µ±È»£¬Õâ˵Ã÷ÎÒÃǶ¼ºÜ×¢ÖغÜÈÝÒ׵ؿª·¢ Web ±íʾ²ãµÄÄÜÁ¦¡£
½á¹ûÊÇ£¬Ê¹ÓÃеÄÒòÌØÍø£¬ÒÔ¼°ÎÒÃÇÊìϤµÄËùÓÐÓïÑÔ£¨Java¡¢C¡¢Perl¡¢Pascal¡¢ Ada ÒÔ¼°ÆäËûÓïÑÔ£©¶¼²»ÏñÎÒÃÇËùÏ£ÍûµÄÄÇôÈÝÒס£µ±½«Ã¿¸öÈ˶¼Ê¹Óõıà³ÌÓïÑÔÓÃÓÚºó¶Ë³ÌÐò²¢Éú³ÉÊÊÓÃÓÚ¿Í»§»úµÄ±ê¼ÇÓïÑÔʱ£¬»á³öÏÖÒ»´óÁ¿µÄÎÊÌâ¡£Ëæ×Åä¯ÀÀÆ÷Ìṩ¸ü¶àµÄÑ¡ÏÀýÈç DHTML ºÍ
JavaScript ±àÂ룩¡¢Web ÁìÓòͼÐÎÒÕÊõÈ˲ŵÄÔö¼Ó¡¢ÒÔ¼°Äܹ»Ê¹Óñê×¼ HTML Éú³É¸´ÔÓ½çÃæµÄ¹¤¾ßµÄ³öÏÖ£¬¶Ô±ð¾ßÒ»¸ñµÄÓû§½çÃæµÄÐèÇó±ÈÎÒÃÇ¿ª·¢ÕâЩӦÓóÌÐòÇ°¶ËµÄÄÜÁ¦Ôö³¤µÃ»¹Òª¿ì¡£Õâ¾Íµ¼ÖÂÁ˱íʾ¼¼ÊõµÄÐËÆð¡£
±íʾ¼¼ÊõÉè¼ÆÓÃÀ´Ö´ÐÐÒ»ÏîÈÎÎñ£º½«ÄÚÈÝ£¨¼´²»´øÏÔʾÏêϸÐÅÏ¢µÄÊý¾Ý£©×ª»»Îª±íʾ -- ¼´ÄúÔڵ绰¡¢ÕÆÉϵçÄÔ»ò Web ä¯ÀÀÆ÷Öп´µ½µÄ¸÷ÖÖÓû§½çÃæ¡£ÕâЩ±íʾ¼¼ÊõÉù³ÆÄܹ»½â¾öÄÄЩÎÊÌ⣿ÈÃÎÒÃÇÀ´¿´Ò»Ï¡£
¸ôÀëÓ뼯³É
±íʾ¼¼ÊõµÄ×î»ù±¾Ä¿µÄÊÇʹµÃÄÚÈݺͱíʾ¿ÉÒÔ·ÖÀ뿪À´¡£»»ÑÔÖ®£¬ÒµÎñÂß¼µ¥Ôª£¨¿ÉÄÜÓà C »ò Java
ÓïÑÔ±àд£©²»±ØÒÔ±íʾÌض¨µÄ·½Ê½Éú³É´úÂë¡£Êý¾Ý»òÕßÄÚÈÝÒÔÔʼÐÎʽ·µ»Ø£¬²»´øÈκθñʽ¡£Ö®ºó£¬±íʾ¼¼ÊõΪÕâЩÄÚÈÝÌí¼Ó¸ñʽ»ò±íʾ¡£½á¹ûÊÇ£¬Êý¾Ý±»Í¼ÐΡ¢¸ñʽ¡¢ÑÕÉ«ºÍ»Õ±ê»·ÈÆ°üΧÆðÀ´¡£
Çë¿´Çåµ¥ 1 ºÍÇåµ¥ 2 ÖеÄʾÀý£¬¿´Ò»ÏÂÔʼÄÚÈݺͽáºÏÁ˱íʾ¼¼ÊõµÄÄÚÈÝÖ®¼äµÄÇø±ð¡£
Çåµ¥ 1 ÏÔʾµÄÊÇÔʼÄÚÈÝ£¬³ýÁËÊý¾ÝÍâ±ðÎÞËûÎ¿ÉÒÔͨ¹ý¶àÖÖ·½Ê½Ê¹Óá£
Çåµ¥ 1. Ö»°üº¬Êý¾ÝµÄÔʼÄÚÈÝ Russell Crowe
Tom Hanks
Meg Ryan
Mary Stuart Masterson
Alec Baldwin
Ashley Judd
Keanu Reeves
Çåµ¥ 2 ¾Í±ÈÉÏÒ»¸öÇåµ¥¸´ÔÓ¶àÁË£¬ËüÏÔʾµÄÊÇÏàͬµÄÊý¾Ý£¬µ«ÕâЩÊý¾Ý°ü×°ÔÚ±íʾ¼¼ÊõÖУ¬²¢ÇÒËæʱ¿ÉÒÔÔÚÖ§³Ö HTML µÄä¯ÀÀÆ÷ÖÐÏÔʾ¡£
Çåµ¥ 2. Óñíʾ°ü×°µÄÊý¾Ý <HTML>
<HEAD>
<TITLE>ËÑË÷½á¹û£ºÑÝÔ±</TITLE>
</HEAD>
<BODY>
<H2 ALIGN="center">ËÑË÷½á¹û£ºÑÝÔ±</H2>
<CENTER>
<HR WIDTH="85%">
<TABLE WIDTH="50%" CELLPADDING="3" CELLSPACING="3" BORDER="1"
BGCOLOR="#FFFFCC">
<TR BGCOLOR="#FFCCCC">
<TH WIDTH="50%" ALIGN="center">ÐÕ</TH>
<TH WIDTH="50%" ALIGN="center">Ãû</TH>
</TR>
<TR>
<TD WIDTH="50%">Baldwin</TD>
<TD WIDTH="50%">Alec</TD>
</TR>
<TR>
<TD WIDTH="50%">Crowe</TD>
<TD WIDTH="50%">Russell</TD>
</TR>
<TR>
<TD WIDTH="50%">Hanks</TD>
<TD WIDTH="50%">Tom</TD>
</TR>
<TR>
<TD WIDTH="50%">Judd</TD>
<TD WIDTH="50%">Ashley</TD>
</TR>
<TR>
<TD WIDTH="50%">Masterson</TD>
<TD WIDTH="50%">Mary Stuart</TD>
</TR>
<TR>
<TD WIDTH="50%">Reeves</TD>
<TD WIDTH="50%">Keanu</TD>
</TR>
<TR>
<TD WIDTH="50%">Ryan</TD>
<TD WIDTH="50%">Meg</TD>
</TR>
</TABLE>
</CENTER>
</BODY>
</HTML>
Çåµ¥ 1 ÖеÄÄÚÈݶԺÁÎÞ¾ÑéµÄÍâÐÐÈËÀ´Ëµ£¬Ò×ÓÚÀí½â£¬Ò²±ãÓÚʹÓá£Çåµ¥ 2 ÖеÄÄÚÈÝÔòרÓÃÓÚÔÚä¯ÀÀÆ÷ÖÐÏÔʾ¡£´ÓÇåµ¥ 2 ÖÐÌáÈ¡Êý¾Ý£¬»ò´¦ÀíËüÓÃÓÚÆäËûÄ¿µÄ£¬¾ÍÐèÒªÓÐһЩ¼¼ÇÉ¡£
ÕâÒ»»ù±¾Çø±ð -- ½«±íʾºÍÄÚÈÝ·Ö¿ª¶ø²»ÊǼ¯³ÉÔÚÒ»ÆðµÄ´¦Àí(ÖÁÉÙÔÚÓû§²»ÐèÒªÕâЩÐÅϢʱÊÇÕâÑù), ÊDZíʾ¼¼Êõ£¨°üÀ¨ JSP ¼¼Êõ£©µÄÇ°Ìá¡£½øÒ»²½Ëµ£¬Ã»ÓдﵽÕâÒ»»ù±¾Ä¿±êµÄ±íʾ¼¼Êõ¾ÍûÓÐÕæÕýʵÏÖÉè¼ÆµÄ×î³õÄ¿µÄ¡£
±àдÓëÐÞ¸Ä
³ýÁ˽«ÄÚÈݺͱíʾ·ÖÀ뿪À´ÒÔÍ⣬ºâÁ¿±íʾ¼¼ÊõÊÇ·ñÓÐÓõÄÁíÍâÒ»¸öÒòËØÔòÊÇËüËùÃâ³ýµÄÐ޸Ť×÷Á¿¡£±íʾºÍÄÚÈݵķÖÀë¼Ó´óÁËÄÚÈÝ¿ª·¢ÈËÔ±µÄ½ÇÉ«²î±ð¡£³ÌÐòÔ±¿É½«×¢ÒâÁ¦¼¯ÖÐÔÚÇ°ÃæʾÀýÖеÄÔʼÄÚÈÝÉÏ£¬Í¼ÐÎÒÕÊõ¼Ò»òÍøÕ¾¹ÜÀíÔ±Ôò¿É½«¾«Á¦·ÅÔÚ±íʾÉÏ¡£µ«ÊÇ£¬ÔÚ°ÑÒÕÊõ¼ÒÉè¼ÆµÄ±íʾ»ò
±ê¼ÇÈ¡³ö²¢¼ÓÈëµ½³ÌÐòÔ±±àÖƵÄÄÚÈÝÖÐʱ£¬»¹»á³öÏÖһЩ½ÇÉ«½»µü¡£
ÔÚ×î¼òµ¥µÄÇé¿öÏ£¬ÒÕÊõ¼ÒÌṩ±ê¼Ç£¬¿ª·¢ÈËÔ±Ìṩ´úÂë²¢½«±ê¼Ç²åÈë±íʾ¼¼ÊõÖС£È»ºó£¬Ó¦ÓóÌÐò¡°Æô¶¯¡±£¬ÄÚÈÝ»áħÊõ°ãµØ±ä³ÉÒ»¸öÓû§½çÃæ¡£µ±È»£¬ÎÒÃǶ¼ÖªµÀ£¬¿ª·¢¹¤×÷ͨ³£²»»á½öÖ¹ÓÚ´Ë¡£ÏÂÒ»²½ÊÇÐÞ¶©ºÍ¸ü¸Ä½çÃ棬²¢±àÖÆеÄÒµÎñ¹æÔò£¬ÕâÕýÊǼìÑé±íʾ¼¼ÊõÁé»îÐԵĵط½¡£ËäÈ»
¸üÐÂÊäÈëµ½±íʾ²ãÖеÄÔʼÊý¾Ýͨ³£²¢²»ÄÑ£¬µ«ÊÇͼÐÎÒÕÊõ¼Ò¾ÍºÜÄѶÔËûÃǵÄÔʼ×÷Æ·½øÐб༡£¶Ô±íʾ²ãµÄ¸ü¸ÄÊǺܳ£¼ûµÄ£¨ÎÒÃǶ¼±¥ÊܹýÊг¡²¿ÃŸÄÕâ¸ÄÄÇÖ®¿à£©¡£ËùÒÔ£¬ÏÖÔÚ³öÏÖÁËÕâÑùÒ»¸öÎÊÌ⣺Éè¼ÆÈËÔ±Ó¦¸Ã´ÓºÎ´¦ÈëÊÖÀ´¸ü¸ÄËûÃǵŤ×÷£¿ÊÇÐÞ¸ÄËûÃǽ»¸ø¿ª·¢ÈËÔ±µÄÔʼ±ê¼ÇÓïÑÔ
Ò³Â𣿿ÉÄܲ»ÊÇ¡£ÒòΪ×î¿ÉÄܵÄÊÇ£¬´ËÒ³ºÜ¿ÉÄÜÒѲåÈ붨ÖƱê¼Ç»ò´úÂ루JSP Ò³¡¢Ä£°åÒýÇ棩¡¢×ª»¯Îª Java servlet¡¢»òÕßÒѱäµÃÃæÄ¿È«·ÇÁË¡£
ͨ³££¬Éè¼ÆÈËÔ±±ØÐëÔÚÔʼҳÉϽøÐÐÐ޸ģ¬²¢ÔٴΰѴËÒ³½»¸ø¿ª·¢ÈËÔ±¡£¿ª·¢ÈËÔ±±ØÐë°Ñ´ËÒ³ÔÙ´Îת»¯Îª±íʾ¼¼ÊõËùʹÓõÄÌض¨¸ñʽ¡£·ñÔò£¬Éè¼ÆÈËÔ±¾Í±ØÐëѧ»áÒ»Öֽű¾ÓïÑÔ£¬»òÖÁÉÙ¶®µÃ´ËÒ³ÖеÄÄÄЩԴ´úÂëÇøÓòÊǽûÖ¹ÈëÄڵġ£µ±È»£¬ÕâÊÇÒ»ÖÖÈÝÒ׳ö´íµÄ¡¢·Ç³£Î£Ïյķ½·¨¡£Ò»µ©ÄúÈ·¶¨
ÏÂÀ´ÒÔÒ»ÖÖ±íʾ¼¼ÊõÖ§³ÖÄÚÈݺͱíʾ֮¼äµÄÃ÷È··ÖÀ룬Äú¾ÍӦȷ±£¸Ä±ä±íʾËùÐèµÄÐ޸Ť×÷Á¿ÏÞ¶¨ÔÚ×îС¡£
JSP ¼¼ÊõµÄ³Ðŵ
ÏÖÔÚ£¬ÎÒÃÇÀ´ÌÖÂÛ JSP ±àÂëµÄ¾ßÌåÄÚÈÝ¡£JSP ¼¼Êõ³ÐŵΪÉè¼ÆÈËÔ±ºÍ¿ª·¢ÈËÔ±ÌṩËûÃÇËùÐèµÄ×îºÏÊʵıíʾ¼¼Êõ¡£JSP ¼¼ÊõÊÇ J2EE ƽ̨µÄÒ»²¿·Ö£¬ÏÔʾÁË Sun ¹«Ë¾ËùÄܸøÓè Java ²úÆ·µÄ×îÇ¿´óÖ§³Ö¡£ÎªÁËʹÄú¶Ô´Ë½â¾ö·½°¸µÄÁ÷Ðг̶ÈÓÐÒ»¸ö¸ÅÄÄú¿ÉÒÔÊÔ×ÅÔÚ amazon.com
ÉÏËÑË÷һϡ°JSP¡±£¬Äú»á·¢ÏÖ£¬ÂÛÊö JSP µÄÊé¼®±ÈÂÛÊöÆäËûÈκÎÒ»ÖÖ Java API µÄÊé¼®¶¼Òª¶à¡£ÔÚÎÒÉîÈëÌÖÂÛ JSP ¼¼Êõ´æÔÚµÄÌض¨ÎÊÌâ֮ǰ£¬ÄúÐèÒª¶ÔËü³ÐŵµÄ¹¦ÄÜÓÐÒ»¸öÇå³þµÄÁ˽⡣
ÄÚÈÝÓë±íʾ
Ê×ÏÈ£¬JSP ¼¼ÊõÊÇÓÃÀ´·ÖÀëÄÚÈݺͱíʾµÄ£¬ÕâÒ»µã×îÔç³öÏÖÔÚ Sun ¶ÔÓÚ JSP ¹«²¼µÄһϵÁÐÄ¿±êÖС£Êµ¼ÊÉÏ£¬JSP µÄÉè¼ÆÖ±½ÓÕë¶Ô¿ª·¢ÈËÔ±µÄ±§Ô¹£¬ÕâЩ¿ª·¢ÈËÔ±¶ÔÓÚÔÚ servlet ´úÂëÖз´¸´¼üÈë out.println("<HTML><HEAD><TITLE>" + pageInfo.getTitle() + "</TITLE></HEAD>")
¸Ðµ½Ñá·³¡£ÕâÖÖÓ²±àÂëÄÚÈݺÍÔËÐÐʱ±äÁ¿µÄ»ìºÏ¶Ô servlet ¿ª·¢ÈËÔ±Ôì³ÉÁ˾޴óµÄ¸ºµ££¬Ò²Ê¹¿ª·¢ÈËÔ±ÔÚ¶Ô±íʾ²ã½øÐм´±ãÊÇ×îСµÄ¸Ä¶¯Ê±Ò²À§ÄÑÖØÖØ¡£
JSP ¼¼Êõͨ¹ýÖ§³ÖÆÕͨ HTML Ò³£¨ÒÔ¼°ÉÔºóµÄ WML »òÆäËû±ê¼ÇÓïÑÔÒ³£©ÔÚÔËÐÐʱ±àÒëΪ Java servlet£¬¸Ä±äÁËÕâÖÖÇé¿ö¡£Ëüʵ¼ÊÉÏÊÇÄ£·Â out.println() Óï¾ä£¬¶øÎÞÐ뿪·¢ÈËÔ±±àд´úÂ롣ͬʱ»¹ÔÊÐíÔÚÒ³ÃæÖвåÈë±äÁ¿£¬Ö±µ½ÔËÐÐʱ²Å½âÊÍÕâЩ±äÁ¿¡£
Çåµ¥ 2 ËùʾµÄ HTML Ƭ¶ÎÏà¶ÔÓ¦µÄ JSP Ò³Ó¦ÓëÇåµ¥ 3 ÖеÄʾÀýÏàËÆ¡£
Çåµ¥ 3. Ò»¸öʹÓñíʾ¼¼Êõ°üº¬Êý¾ÝµÄ JSP Ò³ <%@ page import="com.ibm.display.PageUtils" %>
<%@ page import="com.ibm.display.PageInfo" %>
<%
PageInfo pageInfo = (PageInfo)session.getAttribute("PAGE_DATA")
%>
<HTML>
<HEAD>
<TITLE>
<%=pageInfo.getTitle()%>
</TITLE>
</HEAD>
<BODY>
<!-- ÆäËû HTML ÄÚÈÝ -->
</BODY>
</HTML>
°´ÕâЩ³õʼÔÔòÅжϣ¬JSP ¼¼Êõ£¨ÖÁÉÙÔÚËüµÄÉùÃ÷Éè¼ÆÖУ©»áÂú×ã±íʾ¼¼ÊõµÄµÚÒ»¸öÔÔò£¬ÈçÉÏËùÊö£º¼´ÄÚÈÝÓë±íʾµÄ·ÖÀë¡£
´úÂëÓë±ê¼Ç
JSP ¼¼ÊõËùÁеĵڶþ¸öÌØÐÔ¿ÉÄÜÒýÆðÄãµÄ×¢Ò⣬ÄǾÍÊÇ£¬JSP ±àÂëÔÊÐíÖ±½ÓÏò±ê¼ÇÒ³ÖвåÈë Java ´úÂ롣ΪÁËÀí½â×÷³öÕâÖÖ¾ö¶¨µÄÔÒò£¬ÎÒÃÇ»ØÏëÒ»ÏÂÖƶ¨ JSP ¹æ·¶Ê±µÄÇé¿ö¡£Sun Óë΢ÈíµÄ¾ºÕùÒ»Ö±·Ç³£¼¤ÁÒ£¬Ö÷ÒªÔ´ÓÚ΢Èí Active Server Pages £¨ASP£©µÄ³É¹¦¡£JavaServer Pages Óë
Active Server Pages ÔÚÃû³ÆÉϵÄÏàËƲ¢·ÇÇɺϡ£¶øÇÒÄ£·Â ASP µÄ¶àÖÖÌØÐÔËƺõÒàÊÇÓÐÒâµÄ¡£ËùÒÔ JSP µÄ×÷ÕßÑ¡ÔñÁËÔÚËûÃǵıê¼ÇÖмÓÈë Java ´úÂë¡£
×÷ΪÏò±ê¼ÇÖмÓÈë Java ´úÂëµÄÒ»¸öÀý×Ó£¬Çåµ¥ 4 ÖÐµÄ JSP Ƭ¶Î×Ô¶¯°´ÐèÒªÌí¼ÓÐУ¬ÒÔÏÔʾÑÝÔ± Vector ÖеÄÿһÏî¡£
Çåµ¥ 4. ²åÈëµ½±ê¼ÇÓïÑÔÒ³ÖÐµÄ Java ´úÂë <%@ page import="com.ibm.display.PageUtils" %>
<%@ page import="com.ibm.display.PageInfo" %>
<%@ page import="com.ibm.people.Actor" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.Vector" %>
<%
PageInfo pageInfo = (PageInfo)session.getAttribute("PAGE_DATA")
Vector actors = pageInfo.getActors()
%>
<HTML>
<HEAD>
<TITLE>
<%=pageInfo.getTitle()%>
</TITLE>
</HEAD>
<BODY>
<H2 ALIGN="center">ËÑË÷½á¹û£ºÑÝÔ±</H2>
<CENTER>
<HR WIDTH="85%">
<TABLE WIDTH="50%" CELLPADDING="3" CELLSPACING="3" BORDER="1"
BGCOLOR="#FFFFCC">
<%
for (Iterator i = actors.iterator(); i.hasNext()) {
Actor actor = (Actor)i.next();
%>
<TR BGCOLOR="#FFCCCC">
<TH WIDTH="50%" ALIGN="center">
<%=actor.getLastName()%>
</TH>
<TH WIDTH="50%" ALIGN="center">
<%=actor.getFirstName()%>
</TH>
</TR>
<%
}
%>
</TABLE>
</CENTER>
</BODY>
</HTML>
Çë¼Çס£¬µ½Ä¿Ç°ÎªÖ¹£¬ÎÒÊÇÔÚ¼òÊöÉè¼Æ JSP ¼¼ÊõµÄ×î³õÄ¿±ê¡£ÔÚºóÃæµÄÕ½ÚÖÐ̸¼°¹ØÓÚ JSP ¼¼ÊõµÄÎÊÌâʱ£¬ÎҲŻá×÷³ö±¾È˶ԴËÄ¿±êµÄÅжϡ£µ«ÊÇ£¬ÄúÏÖÔÚ¿ÉÄÜÒѾÓе㻳ÒÉÁË£¬ÒòΪÏò JSP Ò³ÖÐǶÈë´úÂëËƺõ»áµ¼ÖÂÓë JSP
¼¼ÊõµÄµÚÒ»¸öÄ¿±êÓйصÄÎÊÌ⣨¼´°ÑÄÚÈݺͱíʾ·ÖÀ뿪À´£©¡£µ«ÊÇʵ¼ÊÉÏ£¨°¡¿È£©£¬ÎÒ»¹Ã»Óз¢±íÒâ¼ûÄØ¡£
Éè¼ÆÈËÔ±Ó뿪·¢ÈËÔ±
JSP ¼¼ÊõÖµµÃÒ»ÌáµÄ×îºóÒ»¸ö£¨Ò²ÊÇÖµµÃÔÞÉ͵ģ©Ä¿±êÊÇ£¬ËüÊÔͼÔÚÓ¦ÓóÌÐò¿ª·¢¹ý³ÌÖн¨Á¢Ã÷È·¶¨ÒåµÄ½ÇÉ«¡£Í¨¹ý±íÃæÉϽ«ÄÚÈݺͱíʾ·ÖÀ뿪À´£¬JSP ¼¼ÊõÔÚÉè¼ÆÈËÔ±ºÍ¿ª·¢ÈËÔ±Ö®¼ä»®¶¨ÁËÒ»Ìõ¸ü¼ÓÃ÷ÏԵĽçÏß¡£Éè¼ÆÈËԱֻʹÓñê×¼µÄ
HTML¡¢WML¡¢»òÆäËûÊʵ±µÄÓïÑÔ´´½¨±ê¼Ç£¬¿ª·¢ÈËÔ±±àд´úÂë¡£µ±È»£¬ÏÖÔÚÐí¶àÉè¼ÆÈËÔ±ÒѾѧ»áÁËJavaScript£¬ËùÒÔ²»Ó¦¾ªÆæµÄÊÇ£¬ËûÃÇÖеÄÐí¶àÈËÒ²¿ªÊ¼Ñ§Ï° JSP ±àÂë¡£ºÜ¶àÇé¿öÏ£¬ËûÃDz»Ö»ÊÇ×ö´¿±ê¼Ç£¬¶øÊDZàдÍêÕûµÄ JSP
Ò³£¬²¢°ÑËü½»¸ø¿ª·¢ÈËÔ±¡£½øÐг£¹æµÄµ÷Õûºó£¬¿ª·¢ÈËÔ±°ÑÕâЩ JSP Ò³×÷ΪÕûÌåÓ¦ÓóÌÐòijһ²¿·ÖµÄÇ°¶Ë·ÅÖõ½Êʵ±Î»Öᣵ«¹Ø¼üÊÇ£¬Ðí¶àÉè¼ÆÈËÔ±²»»á JSP ±àÂ룬ËùÒÔÔÚÕâÖÖ»·¾³Öл¹Óй¤×÷¿É×ö¡£
ÎÊÌâ
ÎÒÒÑÇå³þµØ˵Ã÷ÁËÁ¼ºÃµÄ±íʾ¼¼ÊõÓ¦ÌṩµÄ¶«Î÷£¬ÒÔ¼° JSP ¼¼ÊõÊÔͼ½â¾öµÄÌض¨ÎÊÌâ¡£ÏÖÔÚ£¬ÎÒ×¼±¸ÇÐÈëÕýÌ⣺JSP ¼¼ÊõµÄÉè¼ÆËäÈ»Ïë·¨ºÜºÃ£¬µ«ÊÇËü´øÀ´ÁËÏ൱¶àµÄÎÊÌâ¡£ÔÚÑ¡ÔñÔÚÓ¦ÓóÌÐòÖÐʹÓà JSP ֮ǰ£¨Äú¿ÉÄÜÈÔ»áʹÓã©£¬ÄúÓ¦¸ÃÖÁÉÙÖªµÀ¿ÉÄÜ´æÔÚµÄȱÏÝ¡£
ÄúÒ²Ó¦¸ÃÁ˽â J2EE ±à³Ìƽ̨³£±»ºöÊÓµÄÒ»¸öСÎÊÌ⣺´Ëƽ̨ÌṩһÖÖ API ²¢²»Òâζ×ÅÄú±ØÐëʹÓÃËü¡£ÕýÏñÕâ¾ä»°ÌýÆðÀ´ÓеãÓÞ´ÀÒ»Ñù£¬Ðí¶à¿ª·¢ÈËÔ±»¹ÔÚ JSP¡¢EJB »ò JMS API ÖÐÕõÔú£¬ËûÃÇÈÏΪÈç¹û²»Ê¹ÓÃÕâЩ API£¬ËûÃǵÄÓ¦ÓóÌÐò¾ÍÓе㲻ÏñÊÇÕæÕýµÄ¡°J2EE
Ó¦ÓóÌÐò¡±¡£Êµ¼ÊÉÏ£¬´Ëƽ̨³ÐŵµÄÖî¶à API£¬¶Ô´ó¶àÊýÓ¦ÓóÌÐòÀ´Ëµ¶¼²»±ØÒª¡£Èç¹ûÄúÔÚʹÓà JSP ¼¼Êõʱ³öÏÖÎÊÌâ»ò¶ÔËüÓл³ÒÉ£¬ÄúÍêÈ«¿ÉÒÔ²»Ê¹ÓÃËü! ÔÚÑ¡ÔñÔÚÓ¦ÓóÌÐòÖÐʹÓà JSP ¼¼Êõ֮ǰ£¬Çë×Ðϸ¿´Ò»ÏÂËüµÄÓÅȱµã¡£ÏÖÔÚÈÃÎÒÃÇ¿´Ò»ÏÂËüµÄ¼¸¸öȱµã¡£
¿ÉÒÆÖ²ÐÔÓëÓïÑÔËø¶¨
JSP ¼¼Êõ°ÑÄúËø¶¨ÔÚÒ»ÖÖÌض¨µÄÓïÑÔÖС£¶ÔÓÚÕâÒ»µã²»Ó¦¸Ã¿´µÃÌ«ÖØ¡£ÔÚÉè¼ÆÆóÒµÓ¦ÓóÌÐòʱ£¬Java ¼¼ÊõÊÇΨһµÄÓïÑÔÑ¡Ôñ£¨ÖÁÉÙÎҵĹ۵ãÊÇÕâÑù£©¡£ÔÚÕâ¸öÎÊÌâÉÏ£¬Ã»ÓжÀÁ¢ÓÚÓïÑԵĽâ¾ö·½°¸¡£µ±È»£¬ÔÚÓÎÏ·µÄÕâ¸ö½×¶Î£¬ÎÒ»¹²»¿¼ÂÇ Microsoft .NET
ƽ̨µÄÑÌÄ»¼°Æäʵ¼ÊÇé¿ö¡£Ö»ÓÐʱ¼ä»áÖ¤Ã÷ Microsoft .NET ƽ̨ÊÇ·ñ»á·¢Õ¹³ÉΪһ¸öÕæÕý¶ÀÁ¢ÓÚÓïÑԵIJúÆ·¡££¨ÎҺܻ³ÒÉ¡££©
»¹ÓУ¬Ñ¡Ôñ JSP ¼¼Êõ»áÇ¿ÖÆÄúʹÓà Java ÓïÑÔ£¬ÖÁÉÙ¶Ô±íʾºÍÄÚÈݶøÑÔÊÇÕâÑù¡£ËäÈ» CORBA ¿ÉÓÃÓÚÒµÎñÂß¼£¬µ«½øÐÐ JSP ±àÂëȷʵÐèÒªÊìϤһЩ servlet ÒÔ¼°ºËÐÄµÄ Java ÓïÑÔ¡£ÓÉÓÚÐí¶à¿ª·¢ÈËÔ±¶¼ÊÇ´Ó J2EE ƽ̨תÏò JSP ±à³Ì£¬ËùÒÔÕâµãͨ³£²»ÊÇÎÊÌâ¡£
»ìºÏÓë¶ÀÁ¢
ÔÚÈ«ÎÄÖУ¬ÎÒ¶à´ÎÌáµ½°ÑÄÚÈݺͱíʾ·ÖÀëµÄÏë·¨¡£ÄúÒ²ÐíÒѾÌý·³ÁË£¬ÄÇôÏÖÔÚµ½ÁËÎÒÃÇÀ´È·¶¨ JSP ÊÇ·ñÕæµÄʵÏÖÁËÕâ¸öÄ¿±êµÄʱºòÁË¡£ÕýÏñÎÒÒÑ˵¹ýµÄÄÇÑù£¬¼ÈÈ» JSP Éù³ÆÊÇΪÕâÒ»·ÖÀëÄ¿±ê¶øÉè¼ÆµÄ£¬ËùÒÔÎÒÃÇÓ¦¸Ã¼Ù¶¨ËüʵÏÖÁËÕâ¸öÄ¿±ê£¿¶ÔÂð£¿Î´±Ø¡£
Ä£ºýÁËÄÚÈÝÓë±íʾ֮¼äµÄ½çÏÞ
JSP ÔÊÐíÏò±ê¼ÇÓïÑÔÒ³ÖвåÈë Java ´úÂ룬ÕâÒ»µãÏ൱ΣÏÕ£¬ËüÉõÖÁÔÊÐí½«ÄÚÈÝ»ìºÏµ½±íʾÖС£¸üÔãµÄÊÇ£¬ÒµÎñÂß¼¾³£»ìÈë JSP Ò³ÖУ¬ÈçÇåµ¥ 5 Ëùʾ¡£
Çåµ¥ 5. °üº¬ÒµÎñÂß¼µÄ JSP Ò³ <%@ page import="com.ibm.display.PageUtils" %>
<%@ page import="com.ibm.display.PageInfo" %>
<%@ page import="com.ibm.logic.AdminUtils" %>
<%@ page import="com.ibm.people.Actor" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.Vector" %>
<%
PageInfo pageInfo = (PageInfo)session.getAttribute("PAGE_DATA")
%>
<HTML>
<HEAD>
<TITLE>
<%=pageInfo.getTitle()%>
</TITLE>
</HEAD>
<BODY>
<H2 ALIGN="center">ËÑË÷½á¹û£ºÑÝÔ±</H2>
<CENTER>
<HR WIDTH="85%">
<TABLE WIDTH="50%" CELLPADDING="3" CELLSPACING="3" BORDER="1"
BGCOLOR="#FFFFCC">
<%
// ¸ù¾ÝÓû§µÄȨÏÞ£¬Ö´Ðв»Í¬µÄËÑË÷£¨ÒµÎñÂß¼!)
Vector actors = pageInfo.getActors()
if (pageInfo.getUserInfo().hasPermission("ADMINISTRATOR")) {
actors = AdminUtils.getActors(pageInfo.getSearchCriteria());
} else {
actors = pageInfo.getActors();
}
for (Iterator i = actors.iterator(); i.hasNext()) {
Actor actor = (Actor)i.next();
%>
<TR BGCOLOR="#FFCCCC">
<TH WIDTH="50%" ALIGN="center">
<%=actor.getLastName()%>
</TH>
<TH WIDTH="50%" ALIGN="center">
<%=actor.getFirstName()%>
</TH>
</TR>
<%
}
%>
</TABLE>
</CENTER>
</BODY>
</HTML>
JSP µÄÓµ»¤Õß»áÂíÉϸæËßÄú JSP ±ê¼Ç¿â¿ÉÒÔ°ïÖúÄú±ÜÃâÕâÖÖÎÊÌâ¡£±ê¼Ç¿âÔÊÐíÏò JSP Ò³¼ÓÈ붨ÖƵıê¼Ç£¨ÀýÈç<AUTHORS />£©£¬ÕâЩ±ê¼ÇÔÚÔËÐÐʱ½âÊÍΪ±ê¼Ç¿âÖеĴúÂëƬ¶Î¡£
ʹÓö¨ÖƱê¼ÇºÍÏà¹ØµÄ±ê¼Ç¿â»áʹÉÏÃæµÄʾÀý±äΪÇåµ¥ 6 ÖеĴúÂë¡£
Çåµ¥ 6. ½áºÏµ½Ò³ÖеĶ¨ÖƱê¼ÇºÍ±ê¼Ç¿â <CENTER>
<TABLE WIDTH="50%" CELLPADDING="3" CELLSPACING="3" BORDER="1"
BGCOLOR="#FFFFCC">
<ACTORS />
</TABLE>
</CENTER>
ÔÚÔËÐÐʱ£¬Õâ¸ö±ê¼ÇµÄ´úÂë¾Í»áÖ´ÐУ¬ÕýÈ·µÄ½á¹û»á²åÈëµ½Ò³ÖС£µ«ÕⲢûÓнâ¾öÎÊÌâ¡£´Ëʱ£¬¶Ô JSP ¼¼Êõ²»ÀûµÄÂ۵㲻ÔÚÓÚ±íʾºÍÄÚÈÝÊÇ·ñÄܹ»·ÖÀ룬¶øÊÇÔÚÓÚËûÃÇÊÇ·ñ±ØÐë·ÖÀë¡£Ö»Òª JSP
±à³ÌÔÊÐíÄÚǶ´úÂ룬ÔòʹÓÃÄÚǶ´úÂë×÷×îºóµÄÐ޸ľͺÜÈÝÒ×£¨ÌرðÊÇÔÚÏÞÆÚÁÚ½üʱ£©£¬¶ø²»ÊÇ°Ñ´úÂëת»¯µ½±ê¼Ç¿âÖС£Èç¹û²»ÊÇÕâÑù£¬Ç뿼ÂÇһϠJava ÓïÑÔµÄÁ÷ÐÐËÙ¶ÈѸËÙ³¬¹ýC ºÍ C++ µÄÔÒò£ºJava ²»ÔÊÐí C ÖÐÐí¶àÓÐÎÊÌâµÄÌØÐÔ£¬ÀýÈçÖ¸Õë¼Ó·¨¡£¾¡¹ÜÄú×ÜÊÇ¿ÉÒÔÕù±çÔÚ C
Öв»ÊDZØÐëÖ´ÐÐÖ¸Õë¼Ó·¨£¬»òÕßÓÅÐãµÄ³ÌÐòÔ±´ÓÀ´²»»á²åÈë´úÂë scriptlet£¬µ«ÊÇÎÒÃǶ¼ÖªµÀʵ¼ÊÇé¿ö»áÊÇÔõÑù¡£Java ÓïÑÔÓÅÓÚ C£¬ÊÇÒòΪËü½ûÖ¹ÕâÖÖ»µÏ°¹ß³öÏÖ¡£µ« JSP ÔÚÕâÖÖÇé¿öÏ£¬Óë C ÓïÑÔ¼«ÎªÏàËÆ£¬ËüÔÊÐíһЩ»µÏ°¹ß¡£
¶ÔÓÚ JSP ¼¼ÊõÊÇ·ñ´ïµ½ÁËËüËùÐû³ÆµÄÄ¿±ê, »¹ÓÐÒ»¸ö²âÊÔ±ê×¼£¬¾ÍÊÇ¿´Ëüʵ¼ÊÉÏÊÇ·ñÄܹ»´ïµ½Ä¿±ê¡£µ±È»£¬ÒÔ²»¿ÉÄÜ´ïµ½µÄ±ê×¼À´ÒªÇó JSP ÊDz»¹«Æ½µÄ¡£´ó¶àÊýÄ£°åÒýÇ棨ÀýÈç FreeMarker ºÍ WebMacro£©ÓÐÕâÖÖÏàͬµÄÄÚǶ´úÂ빦ÄÜ£¬Í¨³£ÕâЩģ°åʹÓÃÀàËÆ Perl µÄÓïÑÔ¡£µ«ÊÇ£¬Ïñ
Enhydra µÄ XMLC ÕâÑùµÄ¼¼Êõ£¬²»ÔÊÐíÕâÖÖÄÚǶ´úÂë¡£ÕâЩ¼¼ÊõʹÓÃÒ»¸ö´¿±ê¼ÇÓïÑÔÒ³×÷ΪÊäÈëÀ´´úÌ棬²¢Éú³É Java ·½·¨¡£ÕâÖÖ×ö·¨ÊµÖÊÉÏÊǸıäÁ˳ÌÐòÁ÷£¬¶ø²»ÊÇÒ³Ã棨JSP ¼¼Êõ£©µ÷ÓÃÓ¦ÓóÌÐòµÄÂß¼£¬Ó¦ÓóÌÐò£¨Enhydra£©Ê¹Ó÷½·¨À´Ó°ÏìÒ³ÃæÖеÄÖµ¡£ÔÚ Enhydra
µÄÌض¨Çé¿öÏ£¬XMLC °ÑÒ³Ãæת»¯ÎªÒ»¸ö DOM Ê÷£¬²¢Ê¹Óà DOM µÄ HTML °ó¶¨À´ÔÊÐíÒ³ÖС°Óò¡±µÄ¸üС££¨¹ØÓÚ Enhydra XMLC µÄÏêϸÐÅÏ¢£¬Çë²ÎÔIJο¼×ÊÁÏ¡££©
ÔÚÕâÒ»µãÉÏ£¬JSP ±È XMLC ÎÊÌâ¸üÑÏÖØ¡£ÀýÈ磬ËäÈ» JSP ¼¼ÊõÄܹ»ÊµÏÖËüµÄÄ¿±ê£¬µ«ÊÇËüÖ»ÔÊÐíʹÓñê¼Ç¿â¡£µ«ÊÇ£¬Sun ¹æ·¶ÖеÄ×ÜÇ÷ÊÆÊÇʼÖÕ±£³ÖÏòºó¼æÈÝ£¬»òÖÁÉÙ±£³ÖÏ൱³¤µÄÒ»¶Îʱ¼ä¡£µ±Ç°°æ±¾µÄ JSP 1.1 ÔÊÐíʹÓà scriptlet£¬ËùÒÔ¹À¼Æ JSP
Ò³°üº¬´úÂëÕâÒ»Çé¿ö»¹ÒªÎ¬³Ö¼¸Äê¡£ÔÚÉîÈë̽ÌÖ JSP ±àÂëÇ°£¬Çë×¢ÒâËüʵ¼ÊÌṩÁ˲úÆ·£¨ËüÖÁ¶à²»¹ýÊÇÓû§½çÃæºÍÇý¶¯Ó¦ÓóÌÐòµÄ´úÂëÖ®¼äµÄα·ÖÀ룩ºÍËüµÄÄ¿±ê£¨¼´ÍêÈ«·ÖÀëÄÚÈݺͱíʾ£©Ö®¼äÈÔÓÐÏ൱´óµÄ²î¾à¡£
µ¥Ò»´¦ÀíÓë¶àÈÎÎñ
ÈçÉÏÌÖÂÛ£¬ÀíÏëÇé¿öÏ£¬Éè¼ÆÈËÔ±Ó¦¸ÃÖ»Ö´Ðе¥Ò»´¦Àí£¬¼´Ö»½øÐÐͼÐÎÉè¼Æ¹¤×÷£¬¿ª·¢ÈËÔ±Ó¦¸ÃÖ»×¢ÖØÓÚ±àÂë¡£ÕâÑù£¬ÔÚÒ»¸öÒ³Ãæת»¯ÎªÓ¦ÓóÌÐòËùʹÓõĸñʽºó£¬Éè¼ÆÈËÔ±Ó¦Äܹ»ÐÞ¸ÄËü¡£ÔÚ JSP Ò³µÄÇé¿öÏ£¬ÕâÓ¦¸ÃÔÚµ¼Èë
JavaBean¡¢²åÈëÄÚǶ´úÂë¡¢ÔÚÒ³ÖмÓÈ붨ÖƱê¼Ç¿âÖ®ºó¡£ÎÊÌâÊÇÓÐЩÉè¼ÆÈËԱʹÓà HTML ±à¼Æ÷£¬Èç HoTMetaL¡¢Macromedia Dreamweaver »ò FrontPage£¬ÕâЩ±à¼Æ÷²»ÄÜʶ±ð´úÂë scriptlet
»ò±ê¼Ç¿â£¬ÕâÒâζ×ÅÉè¼ÆÈËԱʵ¼ÊÉÏÖ»ÊÕµ½Á˲¿·ÖÒ³Ãæ¡£µ±±ê¼Ç¿â»ò´úÂë¶ÎÔÚÒ³ÖвúÉú±í¸ñÐлòÆäËû¸ñʽµÄ¾ßÌåÄÚÈÝʱ£¬ÆäÀ§Äѳ̶ȿÉÏë¶øÖª¡£Ê¹Óò»¼æÈÝµÄ HTML ±à¼Æ÷£¬Éè¼ÆÈËÔ±ÎÞ·¨¿´µ½ÄÇЩԪËØÊÇʲôÑù×Ó¡£µ±Éè¼ÆÈËÔ±ÎÞ·¨·½±ãµØÐÞ¶©¿ª·¢ÈËÔ±±àÒëºóµÄÒ³Ãæʱ£¬JSP
±àÂë²»ÊǰѲ»Í¬µÄ½ÇÉ«Çø·Ö¿ªÀ´£¬¶øÊÇʹÕâЩ½ÇÉ«ºÏ²¢ÔÚÒ»Æ𣺿ª·¢ÈËÔ±±ØÐëÄܹ»Íê³É¶àÖÖÈÎÎñ£¬³ÉΪ¿ª·¢ÈËÔ±¼æÉè¼ÆÈËÔ±²¢³Ðµ£ÆäËû½ÇÉ«¡£
ÕâÖÖÖØÒªÌØÐÔûÓÐʹÄúÐÅ·þÂð£¿ÄÇôÄú¿ÉÒÔÏÂÔØ J2EE ²Î¿¼ÊµÏÖ£¬²¢°ÑÆäÖÐÈÎÒâÒ»¸ö°üº¬µÄ JSP Ò³µ÷ÈëËù¼û¼´ËùµÃµÄ HTML ±à¼Æ÷£¬Èç Dreamweaver¡£Õâ¸öÒ³ÃæÁ¢¼´³äÂú»ÆÉ«ÇøÓò£¬Ê¹ÄúÖªµÀ°üº¬ÔÚÒ³ÃæÖеÄËùÓС°·Ç·¨¡±±ê¼Ç¡£µ±È»£¬»ÆÉ«ÇøÓòÊÇÓÉ JSP
±ê¼ÇºÍ´úÂëÔì³ÉµÄ£¬²»ÊÇÒ³ÖеÄÈκÎʵ¼Ê´íÎó¡£
µ½Ä¿Ç°ÎªÖ¹£¬»¹Ã»ÓгöÏÖÈκÎÄܹ»Ö§³Ö JSP µÄËù¼û¼´ËùµÃ±à¼Æ÷£¬ÎÒҲûÓÐÌý˵ÓÐÈËÕýÖÂÁ¦ÓÚ¿ª·¢ÕâÑùµÄ±à¼Æ÷¡£Ä£°åÒýÇæÒàÓÐÕâÖÖÏàͬµÄÎÊÌ⣬Ðí¶à»ùÓÚ Java µÄ·½°¸£¨ÀýÈçÎÒϲ»¶µÄ
Enhydra£©£¬ÔÊÐí°Ñ±ê¼ÇÒ³×÷ΪÊäÈëÌá½»±íʾ¼¼Êõ¡£ÔÚÕâÖÖÇé¿öÏ£¬Éè¼ÆÈËÔ±¿ÉÒÔ·´¸´Ð޸ıê¼ÇÒ³£¬ÔÙ°ÑËüÃÇÖØÐÂÌá½»»ØÈ¥¡£ÔËÐбíʾ¼¼ÊõµÄÒýÇæ»ò±àÒëÆ÷¿ÉÒÔ½«´ËÒ³Ãæת»»ÎªÕýÈ·µÄ¸ñʽ£¬²¢ÇÒ²»ÐèÒª¸Ä±ä´úÂ루ÔÚͨ³£Çé¿öÏ£©¡£½á¹ûÕýÊÇÎÒÃÇËùÏ£ÍûµÄ£ºÉè¼ÆÈËÔ±¾ÍÊÇÉè¼ÆÈËÔ±£¬¶ø¿ª·¢ÈËÔ
±¾ÍÊÇ¿ª·¢ÈËÔ±¡£
ËùÒÔ£¬ºÍ JSP ¼¼Êõʵ¼ÊÌṩµÄ¹¦ÄÜÏà±È½Ï£¬ÎÒÏ£ÍûÄúÒ»¶¨ÒªÐ¡ÐĶԴý JSP ¼¼ÊõÌá³öµÄ³Ðŵ¡£Êµ¼ÊÉÏ£¬ÎªÁËʹӦÓóÌÐòÔÚÒ»¸ö JSP ¼¼ÊõÇý¶¯µÄ»·¾³Ï³ɹ¦ÔËÐУ¬Äú±ØÐëÈÃÄúµÄ¿ª·¢ÈËÔ±´¦Àí´óÁ¿±ê¼Ç£¬»òÕßʹÉè¼ÆÈËÔ±ÖÁÉÙѧϰһЩ JSP ±à³Ì¡£
HTML Óë XML
JSP ¼¼ÊõµÄÒ»¸ö×îÑÏÖصÄȱÏÝ£¬Ò²ÊÇ×îÒ×±»ºöÊÓµÄÒ»µã£¬¾ÍÊÇËüÓë XML ²»¼æÈÝ¡£¸ü׼ȷµÄ˵£¬ÓÈÆäÊÇÔÚ HTML ÁìÓòÖУ¬JSP Ò³²»ÐèÒª¼æÈÝ XHTML¡£XHTML ÊÇÒ»¸öÍòάÍøÁªÃË (W3C) ¹æ·¶£¬ËüÏÖÔÚÕýÈ¡´ú HTML 4.0¡£XHTML °´ÕÕÒ»ÖֽṹÍêÕûµÄ XML Îĵµ¶¨Òå HTML ±ê¼Ç¼¯¡£ÀýÈç <br>
±ê¼Ç±ØÐëת»»Îª < br/>£¬ÒÔÈ·±£×ñÊØ XML ¹æ¶¨¡££¨Èç¹ûÄú¾õµÃÕâÒ»µãûÓвûÃ÷Çå³þ£¬¿ÉÒÔ²éÔÄ XML ¹æ·¶ºÍ developerWorks ¹ØÓÚ XHTML µÄÎÄÕ£¬ËüÃÇÔÚÁÐÔڲο¼×ÊÁÏÖС££©Í¼Ïñ±ê¼ÇÒ²ÓÐÀàËƵĹæÔò£¬ÔÚ XHTML 1.1 (×î½üµ®ÉúµÄ) ÖУ¬´ó¶àÊý×ÖÌåÊôÐÔºÍÆäËûÑùʽתÒƵ½ÁË CSS
Ñùʽ±íÖС£ÁíÍ⣬´ó¶àÊý±ê×¼µÄ HTML Îĵµ¿ÉÒÔºÜÈÝÒ×ת»»Îª XHTML 1.0£¬ÕâÒâζ×ÅËüÃǺÜÈÝÒ×ʹÓà XML ¼æÈݵķÖÎö³ÌÐòÔĶÁ£¬ÀýÈç Apache Xerces£¬²¢ÇÒÄܹ»ÒÔ XML ·½Ê½¿ØÖÆ¡£
Äú»áÎÊ£º¡°×îÖØÒªµÄÊÇʲô£¿¡±×îÖØÒªµÄÒ»µã¾ÍÊÇ XML ѸËÙ³ÉΪ»¥ÁªÍøºÍÆóÒµÄÚ²¿ÍøµÄÈ«Çò±ê×¼¡£¶ÔÓÚÈκÎʹÓûù±¾ XML Êý¾Ý´¦Àí¹¤¾ßµÄÆäËûÓ¦ÓóÌÐò£¬ÒÔ XML ¸ñʽ´«ËÍÊý¾Ý£¬ËüÃÇ¿ÉÒÔºÜÈÝÒ×µØʹÓÃÄúµÄÓ¦ÓóÌÐòµÄÊý¾Ý¡£ÊÔÏëһϣ¬Ö»Ðë°ÑÊý¾Ýת»»Îª XML
¸ñʽ¾ÍÄÜÓëÐÅÓÿ¨¹«Ë¾½øÐеç×ÓÉÌÎñͨÐÅ£¡ ºÜ¶àÇé¿öÏ£¬ÄúµÄÊý¾Ý±íʾҲÐèÒªºÍÆäËû¹«Ë¾½»»»Êý¾Ý¡£×î³£¼ûµÄÇé¿öÊÇÃÅ»§Õ¾µãÓ¦ÓóÌÐò£¬Ëü´Ó²»Í¬µÄÌṩÕߣ¨ÀýÈçÌìÆø¡¢¹ÉƱ±¨¼ÛºÍÐÂÎŵȣ©½ÓÊÕÄÚÈÝ£¬ÕâЩÄÚÈÝ»¹³£³£´øÓÐÌṩÕߵıêÖ¾¡£µ«ÊÇ£¬JSP
Ò³ÃæÓÉÓÚ»ìºÏÁË´úÂëºÍ¶¨ÖƱê¼Ç¿â£¬ËùÒÔÎÞ·¨ÔÚÕâÑùµÄ»·¾³ÖÐÁ¼ºÃ¹¤×÷¡£
JSP Ò³¼¸ºõ²»ÊǸñʽÍêÕûµÄ XML Îĵµ£¬¸ü²»ÓÃÌá·ûºÏ XHTMLÁË¡£ÒòΪ XHTMLÊÇÒ»ÖÖ±ê¼ÇÓïÑÔ£¬Ëü²»ÔÊÐí¸÷ÖÖ JSP ¶¨ÖƱê¼Ç¿â¡£µ«ÊǸüÖØÒªµÄÊÇ£¬²åÈëµ½ JSP Ò³ÖеĴúÂëƬ¶Î²»ÊÇÈκÎÐÎʽµÄ±ê¼Ç£¬¶øÇÒÒ»µ©ÓÃÁíÒ»¸öÓ¦ÓóÌÐò´¦ÀíËüÃÇ£¬¾Í»á²úÉú·ÖÎö³ÌÐò´íÎóµÄ¸ºµ£¡£
ÔÚÄú¶ÔÎÒ½øÐÐÆÀÂÛ֮ǰ£¬ÈÃÎÒ½²ÍêÕû¸ö¹ÊÊ¡£Èç¹ûÓ¦ÓóÌÐòÔÊÐíÔʼ¿Í»§»ú¼ÆËã JSP Ò³µÄÖµ£¬Æä½á¹û»áÊÇ´¿ HTML (»ò WML¡¢VoXML
µÈ)¡£µ«ÊÇ£¬´ó¶àÊýÇëÇóÊý¾ÝµÄÓ¦ÓóÌÐòʹÓÃijЩÐÎʽµÄ»º´æ£¬ÒòΪÍøÂçÉϵÄÍù·µÊǺܰº¹óµÄ¡£ÔÚÕâЩÇé¿öÏ£¬»º´æµÄÒ³Ãæ·µ»Ø³Â¾ÉµÄÊý¾Ý¡£ÔÚÕâÖÖÇé¿öÏ£¬Äú¿ÉÄܸüÏ£Íû·µ»ØÍêÈ«·ûºÏ´¿ XML µÄ½á¹û£¬×îºÃÊǾ²Ì¬±íµ¥¡£µ«ÊÇ JSP ¼¼Êõ¶ÔÕâÖÖÇé¿öÎÞÄÜΪÁ¦¡£JSP
Ò³±ØÐëʼÖÕÔÚÔËÐÐʱÇóÖµ£¬ÕâÑù²ÅÄÜÈ¥µô JSP ´úÂë scriptlet ºÍ±ê¼Ç¿â¡£
¼ìÑéһϣºÓÐÆäËû±íʾ¼¼ÊõÄܹ»Íê³ÉÕâ¸öÈÎÎñÂ𣿴ð°¸Êǿ϶¨µÄ¡£ÔÚ´ËÁìÓòµÄ¾ø¶ÔÁìÏÈÕßÊÇ Apache Cocoon ÏîÄ¿£¬ËüÍêÈ«»ùÓÚ XML£¬ÊÇÒ»¸ö XSLT Ñùʽ±íÓ¦ÓóÌÐò£¨¼´¿ÉÔÚÔËÐÐʱӦÓã¬Ò²¿É¾²Ì¬µØÓ¦Óã©¡£ÓÉÓÚ XML Server Pages£¨ÔÚCocoon ¿ò¼ÜÖнÐ×÷ XSP£©Êµ¼ÊÉÏÊÇ XML
Îĵµ£¬ËùÒÔËüÃÇʼÖÕÊÇ·ûºÏ XML µÄ¡£ÆäËûÔÊÐí´¿±ê¼ÇÓïÑÔÒ³ÊäÈëµÄ¼¼Êõ£¨ÀýÈç Tea ºÍ Enhydra XMLC£©Ò²¿ÉÒÔÔÊÐíÕâÒ»µã£¬ËäÈ»ËüÃDz»Ç¿ÖÆÕâÑù×ö¡£ÔÚÕâЩÇé¿öÏ£¬Óû§¿ÉÒÔʹÓà XHTML »ò±ê×¼ HTML¡£µ«ÊÇÕâÑùÈÔÈ»±È JSP µÄÇé¿öÒªºÃ£¬ÒòΪÔÚ JSP ÖÐÎÞ·¨ÎÞ·¨¾²Ì¬ÊµÏÖ¸ñʽÍêÕûµÄ XML¡£
С½á
ÎÒÏ£ÍûÎÒΪÄúÍØ¿íÁËһЩÑ۽磬ʹÄú¿´µ½ÁË JSP ¼¼ÊõµÄÓÅȱµã¡£ÏÖÔÚ£¬Äú¿ÉÒÔ°Ñ JSP ±à³Ì¿´³ÉÊǶàÖÖ±íʾ¼¼ÊõÖеÄÒ»ÖÖ¿ÉÑ¡¼¼Êõ¡£ÔÚÕâÒ»µãÉÏ£¬Äú¿ÉÄܶÔÕûÌåµÄ J2EE ±à³ÌÄ£ÐÍÓÐËù»³ÒÉ¡£ÏÖÔÚÄúÒ²ÐíÏ£Íû¸ü½øÒ»²½Ñо¿´Ëƽ̨µÄÌæ´ú·½°¸£¬²¢ÔÚ Apache Cocoon¡¢Enhydra
ºÍ¶àÖÖÄ£°åÖÐÑ¡ÔñÌæ´ú JSP ±àÂëµÄ·½°¸¡£
×îºó£¬Ó¦¸Ã¼ÇסµÄÊÇ£¬¾¡¹Ü±¾ÎÄËƺõÌá³öÁË·´¶ÔÒâ¼û£¬µ«²¢Ã»Óн¨ÒéÄúʹÓûò²»Ê¹Óà JSP¡£ÎÒÎÞÒâ¹ÄÀøÄúÉîÈëµ½Èκμ¼ÊõµÄÉî²ã̽¾¿ËüÊÇ·ñ·ûºÏÄúµÄÒªÇó¡£±à³ÌÄ£Ð;ÍÏñÊÇÀý×Ó£¬ÓÐʱÐеÃͨ£¬ÓÐʱÐв»Í¨¡£Èý˼¶øºóÐУ¬ÕÒµ½×îÊʺÏÄúµÄ·½°¸ÔÙ×ö¾ö¶¨£¬Õâ×ܱȲÝÂÊ×ö¾ö¶¨ÒªºÃ¡£
ÍæµÃ¿ªÐÄ£¬ÍøÉϼû£¡
²Î¿¼×ÊÁÏ
²ÎÔĵ±Ç°µÄ JSP ¹æ·¶£¬ÒÔ»ñµÃÈ«²¿ÄÚÈÝ¡£
½øÒ»²½²é¿´ JSP 1.2 ÖеÄÐÂÄÚÈÝ¡£
µ£ÐÄ XML µÄ¼æÈÝÐÔÂð? Äú¿ÉÒÔÔĶÁ¹æ·¶ÒÔ¼° Molly Holzschlag µÄÎÄÕ article for developerWorks on getting up to speed£¬ÒÔ»ñµÃ XHTML µÄÏêϸÐÅÏ¢¡£
ÔÚ W3C Style Center ÉÏ»ñµÃÑùʽÎĵµµÄ XML ÊÓͼ¡£
ÐèÒªÖªµÀ±ÈÌṩ JSP ¸ü¶à¹¦ÄÜµÄ J2EE ·½°¸Âð£¿ËüÒ²ÊÇ¿ª·ÅÔ´´úÂëµÄÂð£¿ÇëÔĶÁ½ñÌìµÄ Enhydra¡£
½â·ÅÄúµÄ˼Ï룬¿´Ò»Ï Apache Cocoon£¬ËüÊÇʹÓà XSLT ´¦Àí¶¯Ì¬Ä¿Â¼µÄÁíÒ»¸ö¿ª·ÅÔ´´úÂëµÄÌæ´ú·½°¸¡£
Èç¹ûÄú²»½éÒâÌø³ö Java£¬Ä£°åÒýÇæ¿ÉÒÔ½â¾ÈÄú£¡Á½¸öÖµµÃÒ»¿´µÄÕ¾µãÊÇ WebMacro ºÍ FreeMarker¡£
×÷Õß¼ò½é
Brett McLaughlin ÊÇ Lutris Technologies ¹«Ë¾µÄ Enhydra Õ½ÂÔ¼Ò£¬×¨ÃÅÑо¿·Ö²¼Ê½ÏµÍ³Ìåϵ¡£ËûÊÇ Java and XML (O'Reilly) µÄ×÷Õߣ»´ÓÊ Java servlet¡¢Enterprise JavaBeans ¼¼Êõ¡¢XML ºÍÆóÒµ¶ÔÆóÒµµÄÓ¦ÓóÌÐòµÄÑо¿¡£×î½üÓë Jason Hunter Æð´´½¨ÁË JDOM
ÏîÄ¿£¬´ËÏîĿΪ´Ó Java Ó¦ÓóÌÐò²Ù×Ý XML Ìṩ¼òµ¥µÄ API¡£Ëû»¹ÊÇ Apache Cocoon ÏîÄ¿¡¢EJBoss EJB ·þÎñÆ÷µÄ»îÔ¾¿ª·¢ÈËÔ±£¬²¢ÇÒÊÇ Apache Turbin ÏîÄ¿µÄ´´Ê¼ÈËÖ®Ò»¡£¿ÉÒÔͨ¹ý brett@newInstance.com Óë Brett ÁªÏµ¡£
-- ÔÚʱ¼äÃæÇ°£¬Ã»ÓÐÓÀºã
------Ò»¸öÈÈ°®×ÔÓɵÄÈË
¡ù À´Ô´:¡¤¹þ¹¤´ó×϶¡Ïã bbs.hit.edu.cn¡¤[FROM: 211.100.69.28]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
Ò³ÃæÖ´ÐÐʱ¼ä£º211.537ºÁÃë