caizi
          學習、交流java技術,讓java fans 共享、共進
          posts - 4,comments - 6,trackbacks - 0
          注意:是客戶端的ip,不是獲取本機的ip

          import javax.servlet.http.*;
          import javax.xml.rpc.server.*;
          import org.apache.axis.MessageContext;
          import org.apache.axis.transport.http.HTTPConstants;
          public class BaseService {
          ? public String getClientIp(){
          ??? MessageContext? mc? =? MessageContext.getCurrentContext();
          ??? HttpServletRequest? request? =? (HttpServletRequest)? mc.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
          ??? System.out.println("remote? ip:? "? +? request.getRemoteAddr());
          ??? return request.getRemoteAddr();
          ? }
          }
          posted @ 2006-09-21 14:28 菜籽 閱讀(3717) | 評論 (5)編輯 收藏

          1、配置%CATALINA_HOME%/conf/server.xml文件
          ???在<host>節(jié)點下的<context>節(jié)點中加
          ???<Resource
          ??????????? name="jdbc/oradb"
          ??????????? type="javax.sql.DataSource"
          ??????????? password="123456"
          ??????????? driverClassName="oracle.jdbc.driver.OracleDriver"
          ??????????? maxIdle="20"
          ??????????? maxWait="-1"
          ??????????? username="test"
          ??????????? url="jdbc:oracle:thin:@192.168.0.1:1521:oradb"
          ??????????? maxActive="1000"/>
          2、配置項目的WEB-INF目錄下的web.xml文件,在<web-app>中加
          ?<resource-ref>
          ?<description>ORACLE DB Connection</description>
          ?<res-ref-name>jdbc/oradb</res-ref-name>
          ?<res-type>javax.sql.DataSource</res-type>
          ?<res-auth>Container</res-auth>
          ? </resource-ref>

          3、連接
          ??Context ?initCtx = new InitialContext();
          ???if (initCtx == null)
          ???{
          ????throw new Exception("沒有匹配的環(huán)境!");
          ???}
          ???DataSource ds = (DataSource)initCtx.lookup("java:comp/env/jdbc/oradb");???

          ???if (ds == null)
          ???{
          ????throw new Exception("沒有匹配的數據庫!");
          ???}

          ???con = ds.getConnection();

          一般按照這幾步配置,就能連接成功了!如果這樣配置后還提示
          java:comp is not bound in this Context
          那就檢查你的項目的WEB-INF目錄下lib目錄中是否加進了一些如
          naming-java.jar,naming-common.jar , naming-resources.jar , naming-factory.jar 之類的包,把這些包從lib目錄刪除了,這些包不必放在這里

          posted @ 2006-09-21 10:17 菜籽 閱讀(2420) | 評論 (1)編輯 收藏
          原來在tomcat5.0+axis 1.1下開發(fā)webservices,沒有問題。部署的時候換成tomcat5.5,結果,EchoHeaders.jws?method=list老是報
          <faultcode>soapenv:Server.userException</faultcode>
          <faultstring>java.lang.NullPointerException</faultstring>
          趕緊上網查資料,原來是少 "xercesImpl.jar" and "xml-apis.jar"
          解決:
          ???downloaded Xerces and put the "xercesImpl.jar" and "xml-apis.jar" files inside 項目的WEB-INF/lib/目錄中,問題解決。
          posted @ 2006-09-15 08:56 菜籽 閱讀(3696) | 評論 (0)編輯 收藏
          喜歡java的朋友多多支持,本人在學java web service,客戶端用delphi,有在做相同項目或做過相同項目的朋友多多交流。qq:5555196
          posted @ 2006-06-05 14:41 菜籽 閱讀(161) | 評論 (0)編輯 收藏
          主站蜘蛛池模板: 安义县| 鄱阳县| 玉环县| 三台县| 莎车县| 郧西县| 赞皇县| 湛江市| 烟台市| 雷州市| 淄博市| 广西| 宣恩县| 龙山县| 镇安县| 壤塘县| 克拉玛依市| 高阳县| 安吉县| 阜平县| 若羌县| 潼南县| 交城县| 合作市| 三亚市| 霍邱县| 息烽县| 高青县| 托里县| 平泉县| 吉水县| 民乐县| 常州市| 彭山县| 镇原县| 贵德县| 汽车| 磴口县| 高淳县| 海盐县| 铁岭县|