¿´V512ÊÓƵJsp/Servletѧϰ±Ê¼Ç
//ѧϰ±Ê¼Ç, ¿ÉÄÜÓÐЩµØ·½Àí½âÓÐÎó, »á±í´ï²»Çå³þ
v512_servlet+jsp
01 ÔÚÐÞ¸ÄÍêCookieºó,Ò»¶¨Òª¼ÓÉÏresponse.addCookie(c);
CookieÖÐÖ»Äܱ£´æ×Öĸ»òÊý×ÖÐÅÏ¢;
02 req.getSession()Óëreq.getSession(boolean create)
ÎÞ²ÎÊýµÄ == ÓвÎÊýµÄ²ÎÊýΪtrueʱ
ÓвÎÊýµÄ,µ±²ÎÊýΪtrueʱ,Èç¹ûûÓÐSession¶ÔÏó¾Í´´½¨Ò»¸ö; Èç¹û²ÎÊýΪfalse,Ôò·µ»Ønull;
03 »á»°µÄÏûʧ: ä¯ÀÀÆ÷µÄ¹Ø±Õ; Ö÷¶¯¹Ø±Õ; »á»°³¬Ê±; (????ä¯ÀÀÆ÷¹Ø±Õ)
04 ÈçºÎÓ¦ÓÃEclipseÀ´¿ª·¢Servlet????????
05 TomcatµÄworkĿ¼±£´æÁËËùÓеÄjspת»»³ÉServletµÄËùÓÐÔ´ÎļþºÍ±àÒëºóµÄÎļþ;
06 charset = gbkÓëpageEncoding = gbkЧ¹ûÒ»Ñù;
07 <%@ include file="..." %>: ¿ÉÒÔ°üº¬Ò»¸ö.html/.jspµÈÎļþ½øÀ´;
08 Ö¸Áʽ°üº¬: <%@ include file="logn.jsp" %> °ÑËüµÄÄÚÈÝ°üº¬½øÀ´;
¶¯×÷·½Ê½°üº¬: <jsp:include page="logn.jsp" > µ÷Ó÷½·¨ÊµÏÖ;
<jsp:forward page="logn.jsp" > µÈ¼ÛÓÚ requuest.getRequestDipacher().forward(request,response)
09 ¶ÔÏóÃû:application ---> javax.servlet.ServletContext(ÉÏÏÂÎÄ)
10 ±»ÒýÈëµÄ.classÎļþ²»ÄÜûÓаü??? Èç:count2.jsp
11 ´íÎó´úÂë:
401ÑéÖ¤³ö´í(ÈçÃÜÂë), 404²»´æÔÚµÄ×ÊÔ´, 405Ìá½»·½Ê½²»ÔÊÐí, 505·þÎñÆ÷¶Ë´úÂë´íÎó;
12 javabenaÐèÒª¶¨ÒåÒ»¸öÎ޲εķ½·¨, ÇÒ±ØÐëÒªÓаü, ²»ÄÜʹÓÃÂãÌåÀà;
13 <jsp:useBena setProperty name="..." property="..." /> ĬÈϽÓÊÜformÌá½»¹ýÀ´µÄ²ÎÊý;
JSP EL
01. JSP ELÔËËã·û:
¿ÉÒÔÓÃdivÌæ»»/, ÓÃmodÌæ»»%
and &&, or ||, not !
02. <%@ page isELIgnored="true" %> :Ö¸¶¨µ±Ç°Ò³Ã治ʹÓÃjsp el(Ò²¿ÉÒÔÔÚweb.xmlÖÐÅäÖÃ)
03. ${10 + 10 }Ï൱ÓÚ <%= 10+10 %>, ¿ÉʹÓÃ\$»ò'$'Êä³ö: ×Ö·û$
04. ${username} :Êä³ö×÷ÓÃÓò×îСµÄusernameµÄÊôÐÔÖµ;
Tag Lib
01. (1) ±àдһ¸öclass¼Ì³ÐTagSupport, ÖØдdoStartTag(),doEndTag()·½·¨,
JspWriter out = pageContext.getOut();µÃµ½´
Ïà¹ØÎĵµ£º
£¨Ò»£©°üº¬ÆäËûÒ³ÃæµÄ·½·¨£º
includeÖ¸Á<%@ include file = "test1.jsp" %>
¾²Ì¬°üº¬£¬¿ÉÒÔ°üº¬ÈÎÒâ¸ñʽµÄÎļþ£¨²»¹âÊÇjspÎļþ£¬»¹¿ÉÒÔÊÇtxtµÈÎı¾Îļþ£©£¬¾²Ì¬°üº¬¾ÍÊǽ«±»°üº¬ÎļþµÄÄÚÈÝ¿½±´µ½°üº¬ÎļþÖУ¬½øÐÐÖ´ÐС£µ±Ç°Ò³ÃæºÍtest1.jspÖв»ÄÜÓÐÖØÃûµÄ±äÁ¿¡£
include¶¯×÷ <jsp:include page = "tes ......
jspÓÐËÄÖÖÊôÐÔ·¶Î§£º
page -> Ò³Ã漶±ð£¬ÏÔȻֻÓÐÔÚÒ»¸öÒ³ÃæÄÚ¿ÉÓá£
request -> ÇëÇ󼶱ð ·þÎñÆ÷Ìøת£¬Ò»´ÎÇëÇóÖ®ºóÏûʧ¡£
session -> »á»°¼¶±ð ¿Í»§¶ËÌøת£¨·þÎñÆ÷Ìøת£©£¬Óëä¯ÀÀÆ÷Óйأ¬ieÊÇÔÚÖØдò¿ªieʱ²Å»á²»Í¬¡£
application = Ó¦Óü¶±ð£¬µ±ÖØÆô·þÎñÆ÷ʱ²Å»áÏûʧ
¿Í»§¶ËÌøת ......
<%
Cookie[] cooks = request.getCookies();
String cookieName = "Mycookie";
boolean flag = false;
for(Cookie cook : cooks)
{
if(cook.getName().equals(cookieName))
{
flag = true;
break;
}
}
if(!flag){
String str=System.currentTimeMillis()+"";
Cook ......
±¾ÀýÊDzÉÓÃJSP + Ajax + Îı¾À´ÑÝʾ¶àÑ¡¡¢È«Ñ¡£¬Ìí¼Ó¡¢É¾³ý¡¢¸üÐÂcheckbox¶àÑ¡¿òµÄЧ¹û£»³ä·ÖÕ¹ÏÖÁËÀûÓÃJavaScript¿ØÖÆHTML DOMÒÔ¼°ÀûÓÃXML http ´«µÝÊý¾Ý£¬ÀûÓÃJSP²Ù×÷Îı¾µÄЧ¹û¡£
¡¡¡¡1.JavaScript ÓÃÀ´¿ØÖÆÒ³ÃæÄÚÈݵÄÏÖʵÓëÔöɾЧ¹û£»
¡¡¡¡2.JSP×÷Ϊºǫ́£¬¶ÔÎı¾½øÐжÁÈ¡¡¢Ð´Èë¡¢¸üеȲÙ×÷£»
¡¡¡¡3.Îı¾¸ñʽÊÇÓÃÀ´´ ......
<SCRIPT LANGUAGE="javascript">
//Ö¸¶¨Ò³ÃæÇøÓòÄÚÈݵ¼ÈëWord
function AllAreaWord() {
var oWD = new ActiveXObject("Word.Application");
var oDC = ......