当前位置:首页 » 编程博文
开发技术指南» 文章正文
    引言: 1. 这是4NT-FAMILY: 宋体; mso-ascii-f
 

 

 ·简单的timer例子    »显示摘要«
    摘要:一个简单的timer例子 山哥 http://csdn.blog.net/duoshan 有时想要换一定的间隔时间执行重复的任务,java.util.timer可以很简单的帮你实现。当然你也可以用多线程来实现。下面是用java.util.timer来实现这个功能。 //mytask.java 定义timertask任务,我们会在dotask中调用. //这里只是简单的打印一下任务参数 p......
    摘要:there´s been a certain amount of noise recently surrounding simple jdbc frameworks like ibatis. i´ve liked the idea of ibatis myself, for use in applications which don´t need an obje......


Servlet学习笔记(六)-----Servlet之间的通信
1.       这是4个servlet之间的通信

1)  首先是test.htm文件,它作为客户端访问的页面 【程序编程相关:ASP.NET中使用web.config

2.       代码如下: 【推荐阅读:JSP学习笔记(二)-----使用Tom

<html><head> 【扩展信息:网格的资源发现方法

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">

<meta http-equiv=content-type content="text/html; charset=gb2312">

<meta content="microsoft frontpage 4.0" name=generator></head>

<body>

<center>

<h1>earnest bank </h1></center>

<form action="http://127.0.0.1:8000/servlet/firstservlet" method=post>enter your account number here <input name=accnum size="21"> 

<br><br><br>enter your pin number here&nbsp;&nbsp;&nbsp;&nbsp; <input name=pinnum size="21"> <br>

  <p>

<center><input type=submit value=submit></center></p>

</form></body></html>

 

2)  第一个servelt代码:(作用是检验用户输入account number 与pin number是否合法)

import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

import java.sql.*;

///import javax.sql.*;

 

public class firstservlet extends httpservlet

{

       static connection dbcon;

       static string resulttosecond="na";

      

       protected void dopost(httpservletrequest req,

                      httpservletresponse resp)

               throws servletexception,

                      java.io.ioexception

    {

          

           try

           {

                  class.forname("sun.jdbc.odbc.jdbcodbcdriver");

                  dbcon=drivermanager.getconnection("jdbc:odbc:test","sa","");

                  system.out.println("connection established");

           }

           catch(exception e)

           {

                  system.out.println("database not found!");

           }

          

           //create a share attribute创建一个共享属性

           servletcontext context=this.getservletcontext();

           context.setattribute("accountnumber","");

           //得到从客户端发送过来的两个值

           string accnum=req.getparameter("accnum");

           string pinnum=req.getparameter("pinnum");

          

           //check whether the accountnum and pinnum are valid

           try

           {

                  preparedstatement stat=dbcon.preparestatement(

                             "select * from login where caccount_id=? and cpin_no=?");

                      stat.setstring(1,accnum);

                      stat.setstring(2,pinnum);

                      resultset result=stat.executequery();

                      if(result.next())

                      {

                             resulttosecond=result.getstring(1);

                             context.setattribute("accountnumber",resulttosecond);

                            

                             //the account i valid call the second servlet通过验证后使用requestdispatcher接口

                             //得到以url为参数的servlet的引用

                             requestdispatcher dispatcher=context.getrequestdispatcher("/secondservlet");

                             if(dispatcher==null)

                             {

                                    resp.senderror(resp.sc_no_content);

                             }

                             //把请求提交或者委派给第二个servlet


...   下一页
    摘要:emulex lightpulse fc9002l光纤卡安装日志 光盘上的驱动程序在solaris9上安装有问题,重新启动后系统不停重起,无法up 可以到官方网站下载新的驱动,安装即可. # tar xvf solaris-6.01c-1a.tarx emlxapps300a8-solaris.tar, 6850560 bytes, 13380 tape blocksx lpfc-6.01c......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE