Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 ¾Í³É¹¦ÁË.
 


Ïà¹ØÎĵµ£º

JavaScript ºÍJSP Á¬½ÓSqlServer Êý¾Ý¿â

µÚÒ»ÖÖ JavaScriptÁ¬½ÓÊý¾Ý¿â£º
<mce:script language="JavaScript"><!--
// ´´½¨Êý¾Ý¿â¶ÔÏó
var objdbConn = new ActiveXObject("ADODB.Connection");
// DSN×Ö·û´®
var strdsn = "Driver={SQL Server};SERVER=192.168.0.210;UID=xhb;PWD=xhb;DATABASE=books";
// ´ò¿ªÊý¾ÝÔ´
objdbConn.Open(strdsn);
// ......

BBSϵͳ£¨jsp + servlet+dwr£©

ÓõÄÊÇMySqlÊý¾Ý¿â£¬ÀïÃæÓÐÊý¾Ý¿âµÄ½Å²½£¬ÔËÐÐbbs.sqlÎļþ¾Í¿ÉÒÔÁË¡£
ÓõÄMVCģʽ£¬ÓÃjsp ×öÏÔʾҳÃ棬ÓÃservlet×ö¿ØÖƲ㣬ÓÃJavaBean×öÄ£ÐͲã
ÏÂÔصØÖ·£º
http://www.800disk.com/ContentPane.aspx?down=ok&filepath=lcbjava%2fMybbs.rar
°ÑÉÏÃæµÄµØÖ·¸´ÖƵ½ä¯ÀÀÆ÷¾Í¿ÉÒÔÏÂÔØ ......

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

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

ÒýÓà JDK 6u12+Tomcat6.0+JSP¾­µäÅäÖÃ(Íêȫ׼ȷÎÞÎó£©

µÚÒ»²½£ºJDKÓëTomcatµÈµÄÏÂÔØÓëÅäÖÃ
    ×îеÄJDKΪ6.0£¨jdk-6u12-windows-i586-p.exe£©£¬tomcatΪ6.0(apache-tomcat-6.0.18.exe)
¿ª·¢»·¾³£º
JDK: jdk-6u12-windows-i586-p.exe
ÏÂÔصØÖ·:http://java.sun.com/javase/downloads/index.jsp
Tomcat:apache-tomcat-6.0.18.exe
ÏÂÔصØÖ·:http://tomcat.a ......

jsp´¦ÀíÂÒÂ뺯Êý

<%@ page language="java" contentType="text/html; charset=GBK" %>
<%!
 String   getCh(String   s)   {  
   try   {  
              String &nb ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ