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

jspµ÷ÓÃjni·½·¨

ÎҵĻ·¾³:
--------
1. java±àÒëÆ÷:eclipse 3.0.2
2. web·þÎñÆ÷: tomcat 4.1.24
3. C±àÒëÆ÷: VC6.0
4. ²Ù×÷ϵͳ: win2k
5. javaÔ´ÎļþĿ¼: d:\study\src
6. java±àÒëºóµÄclassÎļþĿ¼: d:\study\bin
7. tomcatĿ¼: d:\tomcat41
1.±àдjavaÎļþ:
//Util.java
package com.jni;
public class Util
{
    public native static int add( int x, int y );
    
    static
    {
        System.loadLibrary( "Util" );
    }
}
±àÒëÕâ¸öÎļþ,Éú³ÉUtil.classÎļþ.
2.Éú³É¶ÔÓ¦µÄÍ·Îļþ:
´ò¿ªÒ»¸ödos´°¿Ú,½øÈë´æ·ÅclassÎļþµÄĿ¼:
d:\>cd d:\study\bin
d:\study\bin\>javah com.jni.Util
ÕâÑù,»áÔÚd:\study\binĿ¼ÏÂÉú³Écom_jni_Util.hÎļþ.
3. ±àдcÎļþ:
ÔÚVC6.0ÖÐ:File->New->Projects->Win32 Dynamic-link Library,Project name ΪUtil, ´´½¨Ò»¸öempty DLL project.
°Ñ2ËùÉú³ÉµÄcom_jni_Util.hÎļþºÍC:\j2sdk1.4.2\includeĿ¼ÏµÄjni.h, C:\j2sdk1.4.2\include\win32Ŀ¼ÏµÄjni_md.h¸´ÖƵ½Util¹¤³ÌĿ¼ÏÂ.
(C:\j2sdk1.4.2ΪÎÒµÄjsdkµÄ°²×°Â·¾¶).
ÔÚUtil¹¤³ÌÖд´½¨Ò»¸öcÔ´Îļþ,ÃûΪUtil.c.
//Util.c
#include "com_jni_Util.h"
JNIEXPORT jint JNICALL Java_com_jni_Util_add
(JNIEnv *env, jclass jc, jint x, jint y)
{
    return x+y;
}
4. Éú³ÉUtil.dll:
±àÒë3ÖеÄUtil.cÎļþºó,»áÉú³ÉUtil.dllÎļþ.
5. Éú³Éjar°ü:
°ÑUtil.classÎļþ´ò³Éjar°ü,ÃûΪmyutil.jar.
6. ±àдjspÎļþ:
//test.jsp
<%@ page import="com.jni.Util" %>
<html>
<head></head>
<body>
<h3>5+7=<%=Util.add( 5, 7 )%></h3>
</body>
</html>
7. °Ñmyutil.jar°ü¸´ÖƵ½d:\tomcat41\common\libĿ¼ÏÂ;
   °ÑUtil.dllÎļþ¸´ÖƵ½d:\tomcat41\binĿ¼ÏÂ(Ò²¿ÉÒÔÊÇ»·¾³±äÁ¿pathµÄËùÉ趨µÄÈκÎÒ»¸öĿ¼ÏÂ);
   °Ñtest.jsp¸´ÖƵ½d:\tomcat41\webapp\testĿ¼ÏÂ.
8. Æô¶¯tomcat.
9. ÔÚieÖÐÊäÈë: http://localhost:8080/test/test.jsp.
   Èç¹ûÄãÄÜ¿´µ½: 5+7=12 ¾Í³É¹¦ÁË.
 


Ïà¹ØÎĵµ£º

Eclipse JSP ±êÇ©×Ô¶¯Ìáʾ


ÎÒÃÇÔÚдһ¸öjspÒ³Ã棬ҪʹÓÃstruts2±êÇ©£¬ÎÒÃÇÒªÊ×ÏÈÒªÔÚjspÒ³ÃæÍ·²¿·Å£º<%@ taglib prefix="s" uri="/struts-tags" %>£¬µ±È»Òª·Åstruts2µÄjar°üÁË¡£ÎÒÃÇ¿ÉÒÔË¢ÐÂһϴËÒ³Ã棬±ÈÈç°ÑÕâ¸öÒ³Ãæ±£´æºóÔÙ´ò¿ª£¬Ä¿µÄÊÇÔÚдstruts2±êǩʱ£¬ÓÐstruts2±êÇ©×Ô¶¯Ìáʾ¹¦ÄÜ¡£
......

jsp»ù´¡ÖªÊ¶£¨ÕûÀí£©

¸Õ¿ªÊ¼Ñ§jsp£¬×öµÄÒ»µãÌý¿Î±Ê¼Ç¡£
1.jspÈý´óÖ¸Áî
 <%@ page ~~~~~~~~ %>
 <%@ include file=""%>
 <%@ taglib  url="" prfix=""%>
2.if(username.equals(""))
 out.println("ÐÕÃû²»ÄÜΪ¿Õ£¬Çë<a href=javascript:history.back()>·µ»Ø")£»
&&·ÀÖ¹Ö±½ÓÔÚä¯À ......

jsp request sessionµÈ¶ÔÏó Ïê½â


jsp request session
µÈ¶ÔÏó

Ïê½â
 
תÕß×¢£º´ËÎÄ×ܽá½ÏΪÏêϸ£¬ÖµµÃ²Î¿¼¡£µ«²¿·ÖÄÚÈݾ­¹ýÕûÀí£¬ÒÔÏÂÊÇÕýÎÄ¡£
 
1.request
¶ÔÏó
 
ÕâÁ½¸ö¶ÔÏóÊÇASPËùÌṩµÄÄÚÖöÔÏóÖÐ×î³£ÓõÄÁ½¸ö¡£ÔÚä¯ÀÀÆ÷£¨»òÆäËûÓû§´úÀí£©ºÍWeb·þÎñÆ÷Ö®¼ä£¬ÇëÇóÓëÏìÓ¦Öз¢ÉúµÄÐÅÏ¢½»Á÷¿ÉÒÔͨ¹ýASPÖеÄÁ½¸öÄÚÖöÔÏóÀ´½øÐÐ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ