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

AJAX+jspÎÞË¢ÐÂÑéÖ¤ÂëʵÀý

[list=1]
ÎÒÃÇÔÚ×öÑéÖ¤ÂëµÄʱºòÍùÍùÓÉÓÚÒª·´×÷±×£¬ÑéÖ¤ÓÐʱ¹ÊÒâ¼ÓÈë¶àµÄ¸ÉÈÅÒòËØ£¬ÕâʱÑéÖ¤ÂëÏÔʾ²»ºÜÇå³þ£¬Óû§¾­³£ÊäÈë´íÎó¡£ÕâÑù²»µ«ÒªÖØÐÂË¢ÐÂÒ³Ã棬µ¼ÖÂÓû§Ã»Óп´Çå³þÑéÖ¤Âë¶øÖØÌî¶ø²»ÊÇÐ޸ģ¬¶øÇÒÈç¹ûûÓÐÓÃsession±£´æÏÂÓû§ÊäÈëµÄÆäËüÊý¾ÝµÄ»°(ÈçÐÕÃû)£¬Óû§¸Õ¸ÕÊäÈëµÄÄÚÈÝÒ²²»´æÔÚÁË£¬ÕâÑù¸øÓû§Ôì³É²»ºÃµÄÌåÑé¡£
±¾ÀýÔÚÔ­ÓÐÑéÖ¤·½Ê½»ù´¡Ö®ÉÏÔö¼ÓÒ»¶Îjs£¬Í¨¹ýxmlhttpÀ´»ñÈ¡·µ»ØÖµ£¬ÒÔ´ËÀ´ÑéÖ¤ÊÇ·ñÓÐЧ£¬ÕâÑù¼´Ê¹Óû§ä¯ÀÀÆ÷²»Ö§³Öjs£¬Ò²²»»áÓ°ÏìËûµÄÕý³£Ê¹ÓÃÁË¡£
ΪÁË·ÀÖ¹×÷±×£¬µ±Óû§Á¬½Ó3´ÎÊäÈë´íÎóʱÔòÖØÔØÒ»ÏÂͼƬ£¬ÕâÑùÒ²ÀûÓÚÓû§ÒòΪͼƬÉϵÄÑéÖ¤Âë±æÈϲ»Çå¶øʹÖÕÎÞ·¨ÊäÈëÕýÈ·¡£
±¾Àý»¹ÌرðÊʺϼìÑéÓû§ÃûÊÇ·ñÓÐЧ£¬Ö»Òª´Óºǫ́×ö¸ösql²éѯ£¬·µ»ØÒ»¸öÖµ»òÊÇxml¼´¿É¡£(ÕâÖÖÀý×ÓÌ«¶à £¬¾ÍÔڴ˲»×¸ÊöÁË)¡£
±¾ÀýµÄÓŵãÔÚÓڷdz£·½±ãÓû§ÊäÈ룬¶øÇÒ¼õÉÙ¶Ô·þÎñÆ÷¶ËµÄÇëÇ󣬿ÉÒÔ˵¼È¸ÄÉÆÓû§ÌåÑé¶øÇÒÂÔ»á½ÚÊ¡´ø¿í³É±¾£¬µ«ÏàÓ¦µØÒªÔÚÒ³ÃæÉÏÔö¼ÓÒ»¶ÎJavaScript´úÂ룬ÔÚÄ¿Ç°ÍøËÙÔ½À´Ô½¿ìÈËÃÇÒªÇó±ã½ÝÊæÊʵĽñÌ죬ËƺõÎÒÃǸüӦעÒâÌṩ¸øÓû§Á¼ºÃµÄʹÓøÐÊÜ¡£ ´úÂëÈçÏ£¬
1,img.jsp,ÊäÈëÖ÷Ò³Ãæ
<%@ page contentType="text/html; charset=GBK" language="java" import="java.sql.*" errorPage="" pageEncoding="GBK"%>
<%
//set Chinese Char
//Cody by JarryLi@gmail.com;
//homepage:jiarry.126.com
request.setCharacterEncoding("GBK");
response.setCharacterEncoding("GBK");
response.setContentType("text/html; charset=GBK");
%>
<html>
<head>
<title>ͼƬÑéÖ¤</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script src="net.js"></script>
</head>
<body>
AJAX(ÎÞˢм°Ê±Ìáʾ)ÑéÖ¤ÂëʵÀý£¡cody by jarry
<hr>
<%
String num=request.getParameter("num");
String random=(String)session.getAttribute("random");
String name=request.getParameter("name");
if(num!=null&&random!=null&&name!=null)
{
if(num.equals(random))
{
  out.println("<font style=\"color:green;font-weight:bold\">¹§Ï²Äú£¬ÑéÖ¤ÂëÊäÈë³É¹¦£¬ÕâÀïÊÇÌá½»½á¹ûÒ³Ã棬¿ÉÒÔдÈëÊý¾Ý¿âÁË£¡</font> <a href=\"img.jsp\">·µ»ØÔÙ²âÊÔ</a><br>");
&nb


Ïà¹ØÎĵµ£º

JSP¼¸ÖÖÌøת·½Ê½

1.RequestDispatcher.forward()
¡¡¡¡ ÊÇÔÚ·þÎñÆ÷¶ËÆð×÷ÓÃ,µ±Ê¹ÓÃforward()ʱ,Servlet engine´«µÝHTTPÇëÇó´Óµ±Ç°µÄServlet or JSPµ½ÁíÍâÒ»¸öServlet,JSP »òÆÕͨHTMLÎļþ,Ò²¼´ÄãµÄformÌá½»ÖÁa.jsp,ÔÚa.jspÓõ½ÁËforward()Öض¨ÏòÖÁb.jsp,´ËʱformÌá½»µÄËùÓÐÐÅÏ¢ÔÚ b.jsp¶¼¿ÉÒÔ»ñµÃ,²ÎÊý×Ô¶¯´«µÝ.
¡¡¡¡µ«forward()ÎÞ·¨Öض¨ÏòÖ ......

jsp Servlet½Å±¾ÔªËØ¡¢Ö¸ÁîºÍÔ¤¶¨Òå±äÁ¿

12.1 JSP½Å±¾ÔªËØ
¡¡¡¡ JSP½Å±¾ÔªËØÓÃÀ´²åÈëJava´úÂ룬ÕâЩJava´úÂ뽫³öÏÖÔÚÓɵ±Ç°JSPÒ³ÃæÉú³ÉµÄServletÖС£½Å±¾ÔªËØÓÐÈýÖÖ¸ñʽ£º
±í´ïʽ¸ñʽ£¼%= expression %£¾£º¼ÆËã±í´ïʽ²¢Êä³öÆä½á¹û¡£
Scriptlet¸ñʽ£¼% code %£¾£º°Ñ´úÂë²åÈëµ½ServletµÄservice·½·¨¡£
ÉùÃ÷¸ñʽ£¼%! code %£¾£º°ÑÉùÃ÷¼ÓÈëµ½ServletÀࣨÔÚÈκη ......

JSP¶¯×÷

JSP¶¯×÷ÀûÓÃXMLÓï·¨¸ñʽµÄ±ê¼ÇÀ´¿ØÖÆServletÒýÇæµÄÐÐΪ¡£ÀûÓÃJSP¶¯×÷¿ÉÒÔ¶¯Ì¬µØ²åÈëÎļþ¡¢ÖØÓÃJavaBean×é¼þ¡¢°ÑÓû§Öض¨Ïòµ½ÁíÍâµÄÒ³Ã桢ΪJava²å¼þÉú³ÉHTML´úÂë¡£
JSP¶¯×÷°üÀ¨£º
jsp:include£ºÔÚÒ³Ãæ±»ÇëÇóµÄʱºòÒýÈëÒ»¸öÎļþ¡£
jsp:useBean£ºÑ°ÕÒ»òÕßʵÀý»¯Ò»¸öJavaBean¡£
jsp:setProperty£ºÉèÖÃJavaBeanµÄÊôÐÔ¡£ ......

jspºÍÊý¾Ý¿âÁ¬½Ó´óÈ«

ÏÂÃæµÄjspºÍÊý¾Ý¿âÁ¬½Ó´óÈ«£¬Çë²Î¿¼
Ò»¡¢jspÁ¬½ÓOracle8/8i/9iÊý¾Ý¿â£¨ÓÃthinģʽ£©
testoracle.jspÈçÏ£º
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
Stri ......

JSPÄÚ½¨¶ÔÏó

¢Ù out - javax.servlet.jsp.jspWriter
   out¶ÔÏóÓÃÓڰѽá¹ûÊä³öµ½ÍøÒ³ÉÏ¡£
·½·¨£º
1. void clear() ;
   Çå³ýÊä³ö»º³åÇøµÄÄÚÈÝ£¬µ«ÊDz»Êä³öµ½¿Í»§¶Ë¡£
2. void clearBuffer() ;
   Çå³ýÊä³ö»º³åÇøµÄÄÚÈÝ£¬²¢Êä³öµ½¿Í»§¶Ë¡£
3. void close() ;
   ¹Ø±ÕÊä³öÁ÷£¬Çå³ýËùÓÐÄÚ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ