JSPÂÒÂëÎÊÌâµÄ½â¾ö
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
¶þ¡¢±íµ¥Ìá½»ÖÐÎÄʱ³öÏÖÂÒÂë
Èý¡¢Êý¾Ý¿âÁ¬½Óʱ³öÏÖÂÒÂë
´ó¼ÒÔÚJSPµÄ¿ª·¢¹ý³ÌÖУ¬¾³£³öÏÖÖÐÎÄÂÒÂëµÄÎÊÌ⣬¿ÉÄÜÒ»ÖÁÀ§ÈÅ×ÅÄú£¬ÎÒÏÖÔÚ°ÑÎÒÔÚJSP¿ª·¢ÖÐÓöµ½µÄÖÐÎÄÂÒÂëµÄÎÊÌâ¼°½â¾ö°ì·¨Ð´³öÀ´¹©´ó¼Ò²Î¿¼¡£
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
ÏÂÃæµÄÏÔʾҳÃæ(display.jsp)¾Í³öÏÖÂÒÂ룺
<html>
<head>
<title>JSPµÄÖÐÎÄ´¦Àí</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<%
out.print("JSPµÄÖÐÎÄ´¦Àí");
%>
</body>
</html>
¶Ô²»Í¬µÄWEB·þÎñÆ÷ºÍ²»Í¬µÄJDK°æ±¾£¬´¦Àí½á¹û¾Í²»Ò»Ñù¡£ÔÒò£º·þÎñÆ÷ʹÓõıàÂ뷽ʽ²»Í¬ºÍä¯ÀÀÆ÷¶Ô²»Í¬µÄ×Ö·ûÏÔʾ½á¹û²»Í¬¶øµ¼Öµġ£½â¾ö°ì·¨£ºÔÚJSPÒ³ÃæÖÐÖ¸¶¨±àÂ뷽ʽ(gb2312),¼´ÔÚÒ³ÃæµÄµÚÒ»ÐмÓÉÏ£º
Ó¢ÎÄ´úÂë<%@ page contentType="text/html; charset=gb2312"%>
¾Í¿ÉÒÔÏû³ýÂÒÂëÁË¡£ÍêÕûÒ³ÃæÈçÏ£º
<%@ page contentType="text/html; charset=gb2312"%>
<html>
<head>
<title>JSPµÄÖÐÎÄ´¦Àí</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<%
out.print("JSPµÄÖÐÎÄ´¦Àí");
%>
</body>
</html>
¶þ¡¢±íµ¥Ìá½»ÖÐÎÄʱ³öÏÖÂÒÂë
ÏÂÃæÊÇÒ»¸öÌá½»Ò³Ãæ(submit.jsp)£¬´úÂëÈçÏ£º
<html>
<head>
<title>JSPµÄÖÐÎÄ´¦Àí</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<form name="form1" method="post" action="process.jsp">
<div align="center">
<input type="text"&nb
Ïà¹ØÎĵµ£º
1.request¶ÔÏó
¿Í»§¶ËµÄÇëÇóÐÅÏ¢±»·â×°ÔÚrequest¶ÔÏóÖУ¬Í¨¹ýËü²ÅÄÜÁ˽⵽¿Í»§µÄÐèÇó£¬È»ºó×ö³öÏìÓ¦¡£ËüÊÇHttpServletRequestÀàµÄʵÀý¡£
ÐòºÅ ·½ ·¨ & ......
pageEncoding
ÔÚJSP±ê×¼µÄÓï·¨ÖУ¬Èç¹ûpageEncodingÊôÐÔ´æÔÚ£¬ÄÇôJSPÒ³ÃæµÄ×Ö·û±àÂ뷽ʽ¾ÍÓÉpageEncoding¾ö¶¨£¬·ñÔò¾ÍÓÉcontentTypeÊôÐÔÖеÄcharset¾ö¶¨£¬Èç¹ûcharsetÒ²²»´æÔÚ£¬JSPÒ³ÃæµÄ×Ö·û±àÂ뷽ʽ¾Í²ÉÓÃĬÈϵÄISO-8859-1¡£
ContentType
ContentTypeÊôÐÔÖ¸¶¨ÁËMIMEÀàÐͺÍJSPÒ³Ãæ»ØӦʱµÄ×Ö·û±àÂ뷽ʽ¡£MIMEÀàÐ굀 ......
´íÎó£º
String realPath = " http:// " + request.getServerName() + " : " + request.getServerPort() + request.getContextPath();
String realPath = " http:// " + request.getSer ......
12.1 JSP½Å±¾ÔªËØ
¡¡¡¡ JSP½Å±¾ÔªËØÓÃÀ´²åÈëJava´úÂ룬ÕâЩJava´úÂ뽫³öÏÖÔÚÓɵ±Ç°JSPÒ³ÃæÉú³ÉµÄServletÖС£½Å±¾ÔªËØÓÐÈýÖÖ¸ñʽ£º
±í´ïʽ¸ñʽ£¼%= expression %£¾£º¼ÆËã±í´ïʽ²¢Êä³öÆä½á¹û¡£
Scriptlet¸ñʽ£¼% code %£¾£º°Ñ´úÂë²åÈëµ½ServletµÄservice·½·¨¡£
ÉùÃ÷¸ñʽ£¼%! code %£¾£º°ÑÉùÃ÷¼ÓÈëµ½ServletÀࣨÔÚÈκη ......