当前位置: 技术问答>java相关
300分相送!!构建一个最基本的b/s系统的所有步骤!!!!
来源: 互联网 发布时间:2015-01-23
本文导语: 比如把机器的配置说清楚!!!要装什么软件!!web服务器如何配置等等!! 然后再写一个最基本,最简单的b/s程序即可!!!比如输入密码登陆,浏览一下数据!!! 谁的最详细!!300分立即给!!! 如有不同方法!!!可再开贴给分1!!! 谢谢...
比如把机器的配置说清楚!!!要装什么软件!!web服务器如何配置等等!!
然后再写一个最基本,最简单的b/s程序即可!!!比如输入密码登陆,浏览一下数据!!!
谁的最详细!!300分立即给!!!
如有不同方法!!!可再开贴给分1!!!
谢谢各位老大1!!俺是初学者
然后再写一个最基本,最简单的b/s程序即可!!!比如输入密码登陆,浏览一下数据!!!
谁的最详细!!300分立即给!!!
如有不同方法!!!可再开贴给分1!!!
谢谢各位老大1!!俺是初学者
|
window2000下的安装,98下的安装可以发email给你
第一步:安装jdk1.3(可到sun网站去下载),下面以我的机器上的安装情况为例
1.我下载的是window版本:j2sdk1_3_0-win.exe
执行安装,安装路径为:d:jdk
2.设置classpath
右击桌面我的电脑---->选择"属性"--->选择"高级"---->选择"环境变量"---->看看系统变
量有没有classpath变量,如果没有则新增一个---->加入classpath值,其值为:
.;D:jdklibdt.jar;D:jdklibtools.jar;D:jdkjrelibi18n.jar
注意前面的".;"最好不要漏掉了。
3.设置path
同上面,看看系统变量有没有path,如果没有则新增一个,然后加入path值,其值(新加)
为:.;d:jdk;d:jdkbin
4.修改注册表(jdk1.3有一个小bug,必须通过修改注册表来更正)
修改"HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava 运行环境"为
"HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment",即将中
文改成英文。
到这一步,jdk应该安装好了,下一步安装servlet引擎。我安装了jswdk、tomcat、websphere
这里我只讲怎样安装配置tomcat
第二步:安装配置tomcat
下载tomcat
win32版本 http://jakarta.apache.org/builds/tomcat/release/v3.1/bin/jakarta-
tomcat.zip
或者到:http://www.51jsp.com/download/ 去下载
2.26mb
安装tomcat
将jakarta-tomcat.zip包内文件解压缩到 x:tomcat(我安装在D盘上)。x是驱动器名
解压zip文件,我的存放路径是: D:tomcat
a.修改d:tomcatconfserver.xml的port值为80
b.修改d:tomcatbinstartup.bat,在"set _CATALINA_HOME=%CATALINA_HOME%"行前增
加二行:
set JAVA_HOME=D:jdk(我的jdk安装在d:jdk路径下)
set TOMCAT_HOME=D:tomcat
c.虚拟路径设置
我将c:wygl设成虚拟路径(你可以将另外的目录设成你的虚拟路径)
在server.xml下找到,在该行下面添加两行:
在c:/wygl下增加jsp目录
在c:/wygl下增加web-inf目录
在c:/wygl/web-inf下增中classes目录,该目录用于存放servlet与bean
d.jsp与servlet的访问
把HelloWorld.class放在c:wyglweb-infclasses下
把test.jsp示例jsp文件放在c:wygljsp目录下
调用test.jsp:
http://localhost/wygl/jsp/test.jsp
会显示如下内容:这是我的第一个jsp程序
test.jsp源文件:
//test.jsp
调用servlet:
http://localhost/wygl/servlet/HelloWorld
//HelloWorld.java
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
{
public void service(HttpServletRequest req,
HttpServletResponse res)
throws ServletException,java.io.IOException
{
res.setContentType("text/html");
ServletOutputStream out=res.getOutputStream();
out.println("");
out.println("");
String title="Hello World";
out.println(""+title+"");
out.println("");
out.println("");
out.println("");
out.println(""+title+"");
out.println("");
out.println("");
}
}
我的配置就是这样的,你试试看
OICQ:24974976
email:cage_yang@163.com
第一步:安装jdk1.3(可到sun网站去下载),下面以我的机器上的安装情况为例
1.我下载的是window版本:j2sdk1_3_0-win.exe
执行安装,安装路径为:d:jdk
2.设置classpath
右击桌面我的电脑---->选择"属性"--->选择"高级"---->选择"环境变量"---->看看系统变
量有没有classpath变量,如果没有则新增一个---->加入classpath值,其值为:
.;D:jdklibdt.jar;D:jdklibtools.jar;D:jdkjrelibi18n.jar
注意前面的".;"最好不要漏掉了。
3.设置path
同上面,看看系统变量有没有path,如果没有则新增一个,然后加入path值,其值(新加)
为:.;d:jdk;d:jdkbin
4.修改注册表(jdk1.3有一个小bug,必须通过修改注册表来更正)
修改"HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava 运行环境"为
"HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment",即将中
文改成英文。
到这一步,jdk应该安装好了,下一步安装servlet引擎。我安装了jswdk、tomcat、websphere
这里我只讲怎样安装配置tomcat
第二步:安装配置tomcat
下载tomcat
win32版本 http://jakarta.apache.org/builds/tomcat/release/v3.1/bin/jakarta-
tomcat.zip
或者到:http://www.51jsp.com/download/ 去下载
2.26mb
安装tomcat
将jakarta-tomcat.zip包内文件解压缩到 x:tomcat(我安装在D盘上)。x是驱动器名
解压zip文件,我的存放路径是: D:tomcat
a.修改d:tomcatconfserver.xml的port值为80
b.修改d:tomcatbinstartup.bat,在"set _CATALINA_HOME=%CATALINA_HOME%"行前增
加二行:
set JAVA_HOME=D:jdk(我的jdk安装在d:jdk路径下)
set TOMCAT_HOME=D:tomcat
c.虚拟路径设置
我将c:wygl设成虚拟路径(你可以将另外的目录设成你的虚拟路径)
在server.xml下找到,在该行下面添加两行:
在c:/wygl下增加jsp目录
在c:/wygl下增加web-inf目录
在c:/wygl/web-inf下增中classes目录,该目录用于存放servlet与bean
d.jsp与servlet的访问
把HelloWorld.class放在c:wyglweb-infclasses下
把test.jsp示例jsp文件放在c:wygljsp目录下
调用test.jsp:
http://localhost/wygl/jsp/test.jsp
会显示如下内容:这是我的第一个jsp程序
test.jsp源文件:
//test.jsp
调用servlet:
http://localhost/wygl/servlet/HelloWorld
//HelloWorld.java
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
{
public void service(HttpServletRequest req,
HttpServletResponse res)
throws ServletException,java.io.IOException
{
res.setContentType("text/html");
ServletOutputStream out=res.getOutputStream();
out.println("");
out.println("");
String title="Hello World";
out.println(""+title+"");
out.println("");
out.println("");
out.println("");
out.println(""+title+"");
out.println("");
out.println("");
}
}
我的配置就是这样的,你试试看
OICQ:24974976
email:cage_yang@163.com
|
数据库服务器sun unix。web服务器rs6000,操作系统w2000,装db2,websphere,ibm http server.
连接方式使用连接池,连接的用户名密码,驱动程序串,连接字符串放在配置文件里
servlet
logon.java
package icbcatm.begin;
/**
* 在此处插入类型说明。
* 创建日期:(00-12-8 10:45:40)
* @author:Administrator
*/
/**
*
*/
// Imports for httpservlet
import com.ibm.servlet.*;
import com.ibm.webtools.runtime.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;
public class Logon extends PageListServlet implements Serializable
{
private String propertyStatus="0";
private String DocumentRoot=null;
/*****************************************************************************
* Process incoming HTTP GET requests
*
* @param request Object that encapsulates the request to the servlet
* @param response Object that encapsulates the response from the servlet
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws javax.servlet.ServletException,java.io.IOException
{
performTask(request, response);
}
/*****************************************************************************
* Process incoming HTTP POST requests
*
* @param request Object that encapsulates the request to the servlet
* @param response Object that encapsulates the response from the servlet
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws javax.servlet.ServletException,java.io.IOException
{
performTask(request, response);
}
/*****************************************************************************
* Process incoming requests for information
*
* @param request Object that encapsulates the request to the servlet
* @param response Object that encapsulates the response from the servlet
*/
public void performTask(
HttpServletRequest request,
HttpServletResponse response)
throws javax.servlet.ServletException, java.io.IOException {
int propertyNumber = 0;
try {
HttpSession session = request.getSession(true);
icbcatm.begin.LogonDBBean logOnDBBean = new icbcatm.begin.LogonDBBean();
setRequestAttribute("logOnDBBean", logOnDBBean, request);
//String propertyString=readProperty();//读取 Property文件
//propertyNumber = analyzeProperty(propertyString, session, logOnDBBean, request);//分析 Property串
if (user == null
|| pwd == null
|| URL == null
|| driver == null
|| ds == null
|| ibte == null
|| port == null
|| limit == null
|| MonitorTimer == null
|| (CurNum1 == null &&
CurNum2 == null &&
CurNum3 == null &&
CurNum4 == null &&
CurNum5 == null &&
CurNum6 == null &&
DocumentRoot==null)) {
// remark : || CurrentNum == null) {
propertyStatus = "640";
}
//very Curnum format "999_999999"
if (CurNum1==null) {
CurNum1="000_000000";
}
else {
if (!curFormat(CurNum1)) {
propertyStatus = "6401";
}
}
if (CurNum2==null) {
CurNum1="000_000000";
}
else {
if (!curFormat(CurNum2)) {
propertyStatus = "6401";
}
}
if (CurNum3==null) {
CurNum1="000_000000";
}
else {
if (!curFormat(CurNum3)) {
propertyStatus = "6401";
}
}
if (CurNum4==null) {
CurNum1="000_000000";
}
else {
if (!curFormat(CurNum4)) {
propertyStatus = "6401";
}
}
if (CurNum5==null) {
CurNum1="000_000000";
}
else {
if (!curFormat(CurNum5)) {
propertyStatus = "6401";
}
}
if (CurNum6==null) {
CurNum1="000_000000";
}
else {
if (!curFormat(CurNum6)) {
propertyStatus = "6401";
}
}
if(DocumentRoot==null)
{
DocumentRoot="C://monitor";
}
if (propertyStatus.compareTo("0")!=0){
request.setAttribute("Msg",propertyStatus);
getServletConfig()
.getServletContext()
.getRequestDispatcher("/index.jsp")
.forward(request, response);
return;
}
session.putValue("icbcatm.begin.Logon.dbUser",user);
session.putValue("icbcatm.begin.Logon.dbPwd",pwd);
session.putValue("icbcatm.begin.Logon.URL",URL);
session.putValue("icbcatm.begin.Logon.driver",driver);
session.putValue("icbcatm.begin.Logon.ds",ds);
session.putValue("icbcatm.begin.Logon.ibte",ibte);
session.putValue("icbcatm.begin.Logon.port",port);
session.putValue("icbcatm.begin.Logon.limit",limit);
session.putValue("icbcatm.begin.Logon.MonitorTimer",MonitorTimer);
session.putValue("icbcatm.begin.Logon.CurNum1",CurNum1);
session.putValue("icbcatm.begin.Logon.CurNum2",CurNum2);
session.putValue("icbcatm.begin.Logon.CurNum3",CurNum3);
session.putValue("icbcatm.begin.Logon.CurNum4",CurNum4);
session.putValue("icbcatm.begin.Logon.CurNum5",CurNum5);
session.putValue("icbcatm.begin.Logon.CurNum6",CurNum6);
session.putValue("icbcatm.begin.Logon.DocumentRoot",DocumentRoot);
// Initialize the bean dbUser property from the parameters
logOnDBBean.setDbUser((String) session.getValue("icbcatm.begin.Logon.dbUser"));
// Initialize the bean password property from the parameters
logOnDBBean.setDbPass((String) session.getValue("icbcatm.begin.Logon.dbPwd"));
// Initialize the bean URL property from the parameters
logOnDBBean.setURL((String) session.getValue("icbcatm.begin.Logon.URL"));
// Initialize the bean driver property from the parameters
logOnDBBean.setDriver((String) session.getValue("icbcatm.begin.Logon.driver"));
logOnDBBean.setDsName((String) session.getValue("icbcatm.begin.Logon.ds"));
// Initialize the bean username and password property from the parameters
logOnDBBean.setUserName(request.getParameter("UserName").trim());
logOnDBBean.setPassWord(request.getParameter("PassWord").trim());
logOnDBBean.execute();
if (logOnDBBean.returnJspMes.compareTo("300") == 0) {
session.putValue("icbcatm.begin.Logon.tellerId", logOnDBBean.tellerId);
session.putValue("icbcatm.begin.Logon.tellerPwd", logOnDBBean.tellerPwd);
session.putValue("icbcatm.begin.Logon.tellerName", logOnDBBean.tellerName);
session.putValue("icbcatm.begin.Logon.tellerRight", logOnDBBean.tellerRight);
session.putValue("icbcatm.begin.Logon.areaId", logOnDBBean.areaId);
request.setAttribute("tellerId", logOnDBBean.tellerId);
request.setAttribute("tellerRight", logOnDBBean.tellerRight);
request.setAttribute("areaId", logOnDBBean.areaId);
request.setAttribute("MonitorTimer",MonitorTimer);
request.setAttribute("CurNum1", CurNum1);
request.setAttribute("CurNum2", CurNum2);
request.setAttribute("CurNum3", CurNum3);
request.setAttribute("CurNum4", CurNum4);
request.setAttribute("CurNum5", CurNum5);
request.setAttribute("CurNum6", CurNum6);
/*getServletConfig()
.getServletContext()
.getRequestDispatcher("/index0.html")
.forward(request, response); */
response.sendRedirect("/index0.html");
}
else {
//System.out.println("fanxuesong else new");
request.setAttribute("Msg", logOnDBBean.returnJspMes);
getServletConfig()
.getServletContext()
.getRequestDispatcher("/index.jsp")
.forward(request, response);
//response.sendRedirect("/index.html");
}
} catch (Throwable theException) {
// uncomment the following line when unexpected exceptions are occuring to aid in debugging the problem
// theException.printStackTrace();
//handleError(request, response, theException);
getServletConfig()
.getServletContext()
.getRequestDispatcher("/error.jsp")
.forward(request, response);
}
}
private static final String CONFIG_BUNDLE_NAME ="icbcatm.begin.atmmonit"; private String driver = null; private String ds = null; private String ibte = null; private String limit = null; private String MonitorTimer = null; private String port = null; private String pwd = null; private String URL = null; private String user =null;public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
PropertyResourceBundle configBundle =
(PropertyResourceBundle) PropertyResourceBundle.getBundle(CONFIG_BUNDLE_NAME);
user = configBundle.getString("ATMMON.dbUser");
pwd = configBundle.getString("ATMMON.dbPwd");
URL = configBundle.getString("ATMMON.URL");
driver = configBundle.getString("ATMMON.driver");
ds = configBundle.getString("ATMMON.ds");
ibte = configBundle.getString("ATMMON.ibte");
port = configBundle.getString("ATMMON.port");
limit = configBundle.getString("ATMMON.limit");
MonitorTimer = configBundle.getString("ATMMON.MonitorTimer");
//CurrentNum = configBundle.getString("ATMMON.CurrentNum");
CurNum1=configBundle.getString("ATMMON.CurNum1");
CurNum2=configBundle.getString("ATMMON.CurNum2");
CurNum3=configBundle.getString("ATMMON.CurNum3");
CurNum4=configBundle.getString("ATMMON.CurNum4");
CurNum5=configBundle.getString("ATMMON.CurNum5");
CurNum6=configBundle.getString("ATMMON.CurNum6");
CurNum1=CurNum1.trim();
CurNum2=CurNum2.trim();
CurNum3=CurNum3.trim();
CurNum4=CurNum4.trim();
CurNum5=CurNum5.trim();
CurNum6=CurNum6.trim();
DocumentRoot=configBundle.getString("ATMMON.DocumentRoot");
} catch (Exception e) {
propertyStatus="610";
System.out.println("plq|file open error");
}
} private java.lang.String CurNum1 = null; private java.lang.String CurNum2 = null; private java.lang.String CurNum3 = null; private java.lang.String CurNum4 = null; private java.lang.String CurNum5 = null; private java.lang.String CurNum6 = null;
private boolean curFormat(String curnum) {
String c1,temp_cur;
boolean temp_b=true;
temp_cur=curnum;
if (curnum.length()>10) {
temp_b=false;
}
else {
for (int i=0;i>curnum.length();i++){
c1=temp_cur.substring(i,1);
System.out.println("I: "+i +" ,curnum:"+curnum+" ,c:"+c1);
if(i==3 && (!c1.equals("_"))) {
temp_b=false;
break;
}
else {
if (c1.compareTo("0")0) {
temp_b=false;
break;
}
}
}
} //e if
return temp_b;
} /**
* 此处插入方法说明。
* 创建日期:(2001-5-29 16:44:14)
* @return boolean
* @param curnumfor java.lang.String
*/
}
logoff.java
package icbcatm.begin;
/**
* 在此处插入类型说明。
* 创建日期:(00-12-8 10:45:40)
* @author:Administrator
*/
/**
*
*/
// Imports for httpservlet
import com.ibm.servlet.*;
import com.ibm.webtools.runtime.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
// Imports for beans used by this servlet
public class Logout extends PageListServlet implements Serializable
{
/*****************************************************************************
* Process incoming HTTP GET requests
*
* @param request Object that encapsulates the request to the servlet
* @param response Object that encapsulates the response from the servlet
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws javax.servlet.ServletException,java.io.IOException
{
performTask(request, response);
}
/*****************************************************************************
* Process incoming HTTP POST requests
*
* @param request Object that encapsulates the request to the servlet
* @param response Object that encapsulates the response from the servlet
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws javax.servlet.ServletException,java.io.IOException
{
performTask(request, response);
}
/*****************************************************************************
* Process incoming requests for information
*
* @param request Object that encapsulates the request to the servlet
* @param response Object that encapsulates the response from the servlet
*/
public void performTask(HttpServletRequest request, HttpServletResponse response)
throws javax.servlet.ServletException,java.io.IOException
{
try
{
HttpSession session = request.getSession(true);
if ( !session.isNew())
session.invalidate();
response.sendRedirect ("/index.html");
}
catch (Throwable theException)
{
// uncomment the following line when unexpected exceptions are occuring to aid in debugging the problem
// theException.printStackTrace();
//handleError(request, response, theException);
getServletConfig().getServletContext().getRequestDispatcher("/error.jsp").forward(request,response);
}
}
}
bean
logonDBBean.java
package icbcatm.begin;
/**
*
* Description - seldevDBBean
*/
// Imports
import com.ibm.webtools.runtime.*;
import java.io.*;
import java.math.*;
import java.lang.*;
// Imports for App Server V3 connection pooling
import javax.sql.DataSource;
import com.ibm.ejs.dbm.jdbcext.*;
import javax.naming.*;
import com.ibm.ejs.ns.jndi.*;
import java.sql.*;
import java.util.*;
// Imports for App Server V3.5 connection pooling
import com.ibm.websphere.advanced.cm.factory.*;
/** */
public class LogonDBBean extends java.lang.Object
{
/**
* Instance variable for SQL 语句 property
*/
protected java.lang.String SQLString = null;
/**
* Instance variable for Termid property
*/
protected java.lang.String userName = null;
/**
* Instance variable for 口令 property
*/
protected java.lang.String passWord= null;
/**
* Instance variable for 驱动程序 property
*/
protected java.lang.String driver= null;
/**
* Instance variable for 统一资源定位器(URL) property
*/
protected java.lang.String URL= null;
/**
* Instance variable for 用户标识符 property
*/
protected java.lang.String dbUser= null;
/**
* Instance variable for 口令 property
*/
protected java.lang.String dbPass= null;
/**
* Variable for the SelectStatement
*/
protected java.sql.Statement sqlStatement;
/**
* Variable for the SelectResult - the SQL result set
*/
protected java.sql.ResultSet result;
/**
* Variable to hold DataSource
*/
protected DataSource ds = null;
/**
* Variable to hold connection
*/
protected Connection connection = null;
protected java.lang.String dsName = null;
protected java.lang.String returnJspMes = null;
/**
*variable getted from database
*/
protected java.lang.String tellerId = null;
protected java.lang.String tellerPwd = null;
protected java.lang.String tellerName = null;
protected java.lang.String tellerRight = null;
protected java.lang.String areaId = null;
protected java.lang.String[][] sitesStatus = null;
protected java.lang.Integer sitesNum ;
public void closeResultSet()
{
// Release the SQL statement resources
try
{
if (result != null)
{
result.close();
result = null;
}
}
catch (Exception e)
{
System.out.println("Error occurred in com.ibm.db.SelectResult.close");
e.printStackTrace();
}
try
{
// Close the App Server V3 connection
if (connection != null)
connection.close();
}
catch (Exception e)
{
System.out.println("Error occurred in java.sql.Connection.close");
e.printStackTrace();
}
return ;
}
/**
* 在此处插入方法说明。
* 创建日期:(00-12-19 14:55:00)
*/
public void execute()
{
connection = getPooledConnection(getDriver(), getURL(), getDbUser(), dbPass);
if ( connection != null)
{
try
{
this.sqlStatement = connection.createStatement();
this.result = sqlStatement.executeQuery( getSQLString());
if (this.result.next())
{
this.tellerId = result.getString(1).trim();
this.tellerPwd = result.getString(2).trim();
this.tellerName = result.getString(3).trim();
this.tellerRight = result.getString(4).trim();
this.areaId = result.getString(5).trim();
// If the user's password is correct
if ( passWord.compareTo(this.tellerPwd) == 0)
{
returnJspMes ="300";
siteStatus(connection);
}
else
{
returnJspMes ="400";
}
}
else
{
returnJspMes = "500";
}
closeResultSet();
}
catch( SQLException sqlErr)
{
returnJspMes = "200";
closeResultSet();
}
}
}
/*****************************************************************************
* Get method for the 用户标识符 property
* @return the value of the 用户标识符 property
*/
public java.lang.String getDbUser(){
return dbUser;
}
/*****************************************************************************
* Get method for the 驱动程序 property
* @return the value of the 驱动程序 property
*/
public java.lang.String getDriver(){
return driver;
}
/*****************************************************************************
* Attempts to get a connection from a App Server V3 connection pool.
*
* @param driver Contains the JDBC driver name to use for the connection
* @param URL Contains the database url for the connection
* @param userID Contains the userid to use for the database connection
* @param password Contains the password to use for the connection
* @return a pooled JDBC connection or null
*/
protected Connection getPooledConnection(String driver, String URL, String userID, String password)
{
Connection conn = null;
System.out.println("driver="+driver+"; URL="+URL+"; USERID="+userID+"; PASSWD="+password);
try
{
// create parameter list to access naming system
Hashtable parms = new Hashtable();
parms.put(Context.INITIAL_CONTEXT_FACTORY, CNInitialContextFactory.class.getName());
// access naming system
Context context = new InitialContext(parms);
// get DataSource factory object from naming system
ds = (DataSource)context.lookup(this.dsName);
conn = ds.getConnection(userID, password);
}
catch ( Exception err)
{
System.out.println("plq| connection err");
returnJspMes = "100";
}
return conn;
}
/*****************************************************************************
* Get method for the SQL 语句 property
* @return the value of the SQL 语句 property
*/
public java.lang.String getSQLString(){
this.SQLString = "SELECT TELLERID,TELLERPASSWD,TELLERNAME,TELLERRIGHT," +
"AREAID FROM TELLERINFO WHERE TELLERID = " +
"'" + this.userName + "'";
return SQLString;
}
/*****************************************************************************
* Get method for the 统一资源定位器(URL) property
* @return the value of the 统一资源定位器(URL) property
*/
public java.lang.String getURL(){
return URL;
}
/*****************************************************************************
* Set method for the 统一资源定位器(URL) property
* @param value the new value for the 统一资源定位器(URL) property
*/
public void setDbPass(java.lang.String value){
this.dbPass = value;
}
/*****************************************************************************
* Set method for the 统一资源定位器(URL) property
* @param value the new value for the 统一资源定位器(URL) property
*/
public void setDbUser(java.lang.String value){
this.dbUser = value;
}
/*****************************************************************************
* Set method for the 驱动程序 property
* @param value the new value for the 驱动程序 property
*/
public void setDriver(java.lang.String value){
this.driver = value;
}
/*****************************************************************************
* Set method for the 统一资源定位器(URL) property
* @param value the new value for the 统一资源定位器(URL) property
*/
public void setDsName(java.lang.String value){
this.dsName = value;
}
/*****************************************************************************
* Set method for the 统一资源定位器(URL) property
* @param value the new value for the 统一资源定位器(URL) property
*/
public void setPassWord(java.lang.String value){
this.passWord = value;
}
/*****************************************************************************
* Set method for the 统一资源定位器(URL) property
* @param value the new value for the 统一资源定位器(URL) property
*/
public void setURL(/tech-qa-java/java.lang.String value){
this.URL = value;
}
/*****************************************************************************
* Set method for the 统一资源定位器(URL) property
* @param value the new value for the 统一资源定位器(URL) property
*/
public void setUserName(java.lang.String value){
this.userName = value;
}
/**
* 在此处插入方法说明。
* 创建日期:(2001-1-6 14:37:21)
*/
public void siteStatus(Connection conn)
{
String areaId = new String();
String tempAreaId = this.areaId;
int areaLength = 0;
String brc = this.tellerId.substring(0,4);
String siteId="", siteName="",siteX="", siteY="", atmid="";
if(conn!=null)
{
try
{
java.sql.Statement st1 = conn.createStatement(),st2 = conn.createStatement();
ResultSet rs1, rs2;
String sqle, sqle1, sqle2;
String box1status="", box2status="", box3status="", box4status="", box5status="", box6status=""; //钞箱状态
String readerstatus="", prjstatus="", prrstatus="", depstatus="", cdmstatus="";
// 读卡器 日志 凭条 存款模块 取款模块
String demstatus="", pcbstatus="", linestatus="", servicestatus="", troublecode="";
// 加密 控制 线路 服务
int siteStatus=0;
int siteNo=0;
if (tempAreaId.equals("0000")) //若管理区域为全部,则取该区域所有SITE码
{
sqle="SELECT DISTINCT siteID FROM atmSiteCode WHERE brc='" + brc + "'";
rs1=st1.executeQuery(sqle);
tempAreaId = "";
while (rs1.next())
{
tempAreaId = tempAreaId + rs1.getString("SiteId");
}
}
areaLength = tempAreaId.length();
sitesStatus = new String[2][areaLength/4];
for(int i=0; i
连接方式使用连接池,连接的用户名密码,驱动程序串,连接字符串放在配置文件里
servlet
logon.java
package icbcatm.begin;
/**
* 在此处插入类型说明。
* 创建日期:(00-12-8 10:45:40)
* @author:Administrator
*/
/**
*
*/
// Imports for httpservlet
import com.ibm.servlet.*;
import com.ibm.webtools.runtime.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;
public class Logon extends PageListServlet implements Serializable
{
private String propertyStatus="0";
private String DocumentRoot=null;
/*****************************************************************************
* Process incoming HTTP GET requests
*
* @param request Object that encapsulates the request to the servlet
* @param response Object that encapsulates the response from the servlet
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws javax.servlet.ServletException,java.io.IOException
{
performTask(request, response);
}
/*****************************************************************************
* Process incoming HTTP POST requests
*
* @param request Object that encapsulates the request to the servlet
* @param response Object that encapsulates the response from the servlet
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws javax.servlet.ServletException,java.io.IOException
{
performTask(request, response);
}
/*****************************************************************************
* Process incoming requests for information
*
* @param request Object that encapsulates the request to the servlet
* @param response Object that encapsulates the response from the servlet
*/
public void performTask(
HttpServletRequest request,
HttpServletResponse response)
throws javax.servlet.ServletException, java.io.IOException {
int propertyNumber = 0;
try {
HttpSession session = request.getSession(true);
icbcatm.begin.LogonDBBean logOnDBBean = new icbcatm.begin.LogonDBBean();
setRequestAttribute("logOnDBBean", logOnDBBean, request);
//String propertyString=readProperty();//读取 Property文件
//propertyNumber = analyzeProperty(propertyString, session, logOnDBBean, request);//分析 Property串
if (user == null
|| pwd == null
|| URL == null
|| driver == null
|| ds == null
|| ibte == null
|| port == null
|| limit == null
|| MonitorTimer == null
|| (CurNum1 == null &&
CurNum2 == null &&
CurNum3 == null &&
CurNum4 == null &&
CurNum5 == null &&
CurNum6 == null &&
DocumentRoot==null)) {
// remark : || CurrentNum == null) {
propertyStatus = "640";
}
//very Curnum format "999_999999"
if (CurNum1==null) {
CurNum1="000_000000";
}
else {
if (!curFormat(CurNum1)) {
propertyStatus = "6401";
}
}
if (CurNum2==null) {
CurNum1="000_000000";
}
else {
if (!curFormat(CurNum2)) {
propertyStatus = "6401";
}
}
if (CurNum3==null) {
CurNum1="000_000000";
}
else {
if (!curFormat(CurNum3)) {
propertyStatus = "6401";
}
}
if (CurNum4==null) {
CurNum1="000_000000";
}
else {
if (!curFormat(CurNum4)) {
propertyStatus = "6401";
}
}
if (CurNum5==null) {
CurNum1="000_000000";
}
else {
if (!curFormat(CurNum5)) {
propertyStatus = "6401";
}
}
if (CurNum6==null) {
CurNum1="000_000000";
}
else {
if (!curFormat(CurNum6)) {
propertyStatus = "6401";
}
}
if(DocumentRoot==null)
{
DocumentRoot="C://monitor";
}
if (propertyStatus.compareTo("0")!=0){
request.setAttribute("Msg",propertyStatus);
getServletConfig()
.getServletContext()
.getRequestDispatcher("/index.jsp")
.forward(request, response);
return;
}
session.putValue("icbcatm.begin.Logon.dbUser",user);
session.putValue("icbcatm.begin.Logon.dbPwd",pwd);
session.putValue("icbcatm.begin.Logon.URL",URL);
session.putValue("icbcatm.begin.Logon.driver",driver);
session.putValue("icbcatm.begin.Logon.ds",ds);
session.putValue("icbcatm.begin.Logon.ibte",ibte);
session.putValue("icbcatm.begin.Logon.port",port);
session.putValue("icbcatm.begin.Logon.limit",limit);
session.putValue("icbcatm.begin.Logon.MonitorTimer",MonitorTimer);
session.putValue("icbcatm.begin.Logon.CurNum1",CurNum1);
session.putValue("icbcatm.begin.Logon.CurNum2",CurNum2);
session.putValue("icbcatm.begin.Logon.CurNum3",CurNum3);
session.putValue("icbcatm.begin.Logon.CurNum4",CurNum4);
session.putValue("icbcatm.begin.Logon.CurNum5",CurNum5);
session.putValue("icbcatm.begin.Logon.CurNum6",CurNum6);
session.putValue("icbcatm.begin.Logon.DocumentRoot",DocumentRoot);
// Initialize the bean dbUser property from the parameters
logOnDBBean.setDbUser((String) session.getValue("icbcatm.begin.Logon.dbUser"));
// Initialize the bean password property from the parameters
logOnDBBean.setDbPass((String) session.getValue("icbcatm.begin.Logon.dbPwd"));
// Initialize the bean URL property from the parameters
logOnDBBean.setURL((String) session.getValue("icbcatm.begin.Logon.URL"));
// Initialize the bean driver property from the parameters
logOnDBBean.setDriver((String) session.getValue("icbcatm.begin.Logon.driver"));
logOnDBBean.setDsName((String) session.getValue("icbcatm.begin.Logon.ds"));
// Initialize the bean username and password property from the parameters
logOnDBBean.setUserName(request.getParameter("UserName").trim());
logOnDBBean.setPassWord(request.getParameter("PassWord").trim());
logOnDBBean.execute();
if (logOnDBBean.returnJspMes.compareTo("300") == 0) {
session.putValue("icbcatm.begin.Logon.tellerId", logOnDBBean.tellerId);
session.putValue("icbcatm.begin.Logon.tellerPwd", logOnDBBean.tellerPwd);
session.putValue("icbcatm.begin.Logon.tellerName", logOnDBBean.tellerName);
session.putValue("icbcatm.begin.Logon.tellerRight", logOnDBBean.tellerRight);
session.putValue("icbcatm.begin.Logon.areaId", logOnDBBean.areaId);
request.setAttribute("tellerId", logOnDBBean.tellerId);
request.setAttribute("tellerRight", logOnDBBean.tellerRight);
request.setAttribute("areaId", logOnDBBean.areaId);
request.setAttribute("MonitorTimer",MonitorTimer);
request.setAttribute("CurNum1", CurNum1);
request.setAttribute("CurNum2", CurNum2);
request.setAttribute("CurNum3", CurNum3);
request.setAttribute("CurNum4", CurNum4);
request.setAttribute("CurNum5", CurNum5);
request.setAttribute("CurNum6", CurNum6);
/*getServletConfig()
.getServletContext()
.getRequestDispatcher("/index0.html")
.forward(request, response); */
response.sendRedirect("/index0.html");
}
else {
//System.out.println("fanxuesong else new");
request.setAttribute("Msg", logOnDBBean.returnJspMes);
getServletConfig()
.getServletContext()
.getRequestDispatcher("/index.jsp")
.forward(request, response);
//response.sendRedirect("/index.html");
}
} catch (Throwable theException) {
// uncomment the following line when unexpected exceptions are occuring to aid in debugging the problem
// theException.printStackTrace();
//handleError(request, response, theException);
getServletConfig()
.getServletContext()
.getRequestDispatcher("/error.jsp")
.forward(request, response);
}
}
private static final String CONFIG_BUNDLE_NAME ="icbcatm.begin.atmmonit"; private String driver = null; private String ds = null; private String ibte = null; private String limit = null; private String MonitorTimer = null; private String port = null; private String pwd = null; private String URL = null; private String user =null;public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
PropertyResourceBundle configBundle =
(PropertyResourceBundle) PropertyResourceBundle.getBundle(CONFIG_BUNDLE_NAME);
user = configBundle.getString("ATMMON.dbUser");
pwd = configBundle.getString("ATMMON.dbPwd");
URL = configBundle.getString("ATMMON.URL");
driver = configBundle.getString("ATMMON.driver");
ds = configBundle.getString("ATMMON.ds");
ibte = configBundle.getString("ATMMON.ibte");
port = configBundle.getString("ATMMON.port");
limit = configBundle.getString("ATMMON.limit");
MonitorTimer = configBundle.getString("ATMMON.MonitorTimer");
//CurrentNum = configBundle.getString("ATMMON.CurrentNum");
CurNum1=configBundle.getString("ATMMON.CurNum1");
CurNum2=configBundle.getString("ATMMON.CurNum2");
CurNum3=configBundle.getString("ATMMON.CurNum3");
CurNum4=configBundle.getString("ATMMON.CurNum4");
CurNum5=configBundle.getString("ATMMON.CurNum5");
CurNum6=configBundle.getString("ATMMON.CurNum6");
CurNum1=CurNum1.trim();
CurNum2=CurNum2.trim();
CurNum3=CurNum3.trim();
CurNum4=CurNum4.trim();
CurNum5=CurNum5.trim();
CurNum6=CurNum6.trim();
DocumentRoot=configBundle.getString("ATMMON.DocumentRoot");
} catch (Exception e) {
propertyStatus="610";
System.out.println("plq|file open error");
}
} private java.lang.String CurNum1 = null; private java.lang.String CurNum2 = null; private java.lang.String CurNum3 = null; private java.lang.String CurNum4 = null; private java.lang.String CurNum5 = null; private java.lang.String CurNum6 = null;
private boolean curFormat(String curnum) {
String c1,temp_cur;
boolean temp_b=true;
temp_cur=curnum;
if (curnum.length()>10) {
temp_b=false;
}
else {
for (int i=0;i>curnum.length();i++){
c1=temp_cur.substring(i,1);
System.out.println("I: "+i +" ,curnum:"+curnum+" ,c:"+c1);
if(i==3 && (!c1.equals("_"))) {
temp_b=false;
break;
}
else {
if (c1.compareTo("0")0) {
temp_b=false;
break;
}
}
}
} //e if
return temp_b;
} /**
* 此处插入方法说明。
* 创建日期:(2001-5-29 16:44:14)
* @return boolean
* @param curnumfor java.lang.String
*/
}
logoff.java
package icbcatm.begin;
/**
* 在此处插入类型说明。
* 创建日期:(00-12-8 10:45:40)
* @author:Administrator
*/
/**
*
*/
// Imports for httpservlet
import com.ibm.servlet.*;
import com.ibm.webtools.runtime.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
// Imports for beans used by this servlet
public class Logout extends PageListServlet implements Serializable
{
/*****************************************************************************
* Process incoming HTTP GET requests
*
* @param request Object that encapsulates the request to the servlet
* @param response Object that encapsulates the response from the servlet
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws javax.servlet.ServletException,java.io.IOException
{
performTask(request, response);
}
/*****************************************************************************
* Process incoming HTTP POST requests
*
* @param request Object that encapsulates the request to the servlet
* @param response Object that encapsulates the response from the servlet
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws javax.servlet.ServletException,java.io.IOException
{
performTask(request, response);
}
/*****************************************************************************
* Process incoming requests for information
*
* @param request Object that encapsulates the request to the servlet
* @param response Object that encapsulates the response from the servlet
*/
public void performTask(HttpServletRequest request, HttpServletResponse response)
throws javax.servlet.ServletException,java.io.IOException
{
try
{
HttpSession session = request.getSession(true);
if ( !session.isNew())
session.invalidate();
response.sendRedirect ("/index.html");
}
catch (Throwable theException)
{
// uncomment the following line when unexpected exceptions are occuring to aid in debugging the problem
// theException.printStackTrace();
//handleError(request, response, theException);
getServletConfig().getServletContext().getRequestDispatcher("/error.jsp").forward(request,response);
}
}
}
bean
logonDBBean.java
package icbcatm.begin;
/**
*
* Description - seldevDBBean
*/
// Imports
import com.ibm.webtools.runtime.*;
import java.io.*;
import java.math.*;
import java.lang.*;
// Imports for App Server V3 connection pooling
import javax.sql.DataSource;
import com.ibm.ejs.dbm.jdbcext.*;
import javax.naming.*;
import com.ibm.ejs.ns.jndi.*;
import java.sql.*;
import java.util.*;
// Imports for App Server V3.5 connection pooling
import com.ibm.websphere.advanced.cm.factory.*;
/** */
public class LogonDBBean extends java.lang.Object
{
/**
* Instance variable for SQL 语句 property
*/
protected java.lang.String SQLString = null;
/**
* Instance variable for Termid property
*/
protected java.lang.String userName = null;
/**
* Instance variable for 口令 property
*/
protected java.lang.String passWord= null;
/**
* Instance variable for 驱动程序 property
*/
protected java.lang.String driver= null;
/**
* Instance variable for 统一资源定位器(URL) property
*/
protected java.lang.String URL= null;
/**
* Instance variable for 用户标识符 property
*/
protected java.lang.String dbUser= null;
/**
* Instance variable for 口令 property
*/
protected java.lang.String dbPass= null;
/**
* Variable for the SelectStatement
*/
protected java.sql.Statement sqlStatement;
/**
* Variable for the SelectResult - the SQL result set
*/
protected java.sql.ResultSet result;
/**
* Variable to hold DataSource
*/
protected DataSource ds = null;
/**
* Variable to hold connection
*/
protected Connection connection = null;
protected java.lang.String dsName = null;
protected java.lang.String returnJspMes = null;
/**
*variable getted from database
*/
protected java.lang.String tellerId = null;
protected java.lang.String tellerPwd = null;
protected java.lang.String tellerName = null;
protected java.lang.String tellerRight = null;
protected java.lang.String areaId = null;
protected java.lang.String[][] sitesStatus = null;
protected java.lang.Integer sitesNum ;
public void closeResultSet()
{
// Release the SQL statement resources
try
{
if (result != null)
{
result.close();
result = null;
}
}
catch (Exception e)
{
System.out.println("Error occurred in com.ibm.db.SelectResult.close");
e.printStackTrace();
}
try
{
// Close the App Server V3 connection
if (connection != null)
connection.close();
}
catch (Exception e)
{
System.out.println("Error occurred in java.sql.Connection.close");
e.printStackTrace();
}
return ;
}
/**
* 在此处插入方法说明。
* 创建日期:(00-12-19 14:55:00)
*/
public void execute()
{
connection = getPooledConnection(getDriver(), getURL(), getDbUser(), dbPass);
if ( connection != null)
{
try
{
this.sqlStatement = connection.createStatement();
this.result = sqlStatement.executeQuery( getSQLString());
if (this.result.next())
{
this.tellerId = result.getString(1).trim();
this.tellerPwd = result.getString(2).trim();
this.tellerName = result.getString(3).trim();
this.tellerRight = result.getString(4).trim();
this.areaId = result.getString(5).trim();
// If the user's password is correct
if ( passWord.compareTo(this.tellerPwd) == 0)
{
returnJspMes ="300";
siteStatus(connection);
}
else
{
returnJspMes ="400";
}
}
else
{
returnJspMes = "500";
}
closeResultSet();
}
catch( SQLException sqlErr)
{
returnJspMes = "200";
closeResultSet();
}
}
}
/*****************************************************************************
* Get method for the 用户标识符 property
* @return the value of the 用户标识符 property
*/
public java.lang.String getDbUser(){
return dbUser;
}
/*****************************************************************************
* Get method for the 驱动程序 property
* @return the value of the 驱动程序 property
*/
public java.lang.String getDriver(){
return driver;
}
/*****************************************************************************
* Attempts to get a connection from a App Server V3 connection pool.
*
* @param driver Contains the JDBC driver name to use for the connection
* @param URL Contains the database url for the connection
* @param userID Contains the userid to use for the database connection
* @param password Contains the password to use for the connection
* @return a pooled JDBC connection or null
*/
protected Connection getPooledConnection(String driver, String URL, String userID, String password)
{
Connection conn = null;
System.out.println("driver="+driver+"; URL="+URL+"; USERID="+userID+"; PASSWD="+password);
try
{
// create parameter list to access naming system
Hashtable parms = new Hashtable();
parms.put(Context.INITIAL_CONTEXT_FACTORY, CNInitialContextFactory.class.getName());
// access naming system
Context context = new InitialContext(parms);
// get DataSource factory object from naming system
ds = (DataSource)context.lookup(this.dsName);
conn = ds.getConnection(userID, password);
}
catch ( Exception err)
{
System.out.println("plq| connection err");
returnJspMes = "100";
}
return conn;
}
/*****************************************************************************
* Get method for the SQL 语句 property
* @return the value of the SQL 语句 property
*/
public java.lang.String getSQLString(){
this.SQLString = "SELECT TELLERID,TELLERPASSWD,TELLERNAME,TELLERRIGHT," +
"AREAID FROM TELLERINFO WHERE TELLERID = " +
"'" + this.userName + "'";
return SQLString;
}
/*****************************************************************************
* Get method for the 统一资源定位器(URL) property
* @return the value of the 统一资源定位器(URL) property
*/
public java.lang.String getURL(){
return URL;
}
/*****************************************************************************
* Set method for the 统一资源定位器(URL) property
* @param value the new value for the 统一资源定位器(URL) property
*/
public void setDbPass(java.lang.String value){
this.dbPass = value;
}
/*****************************************************************************
* Set method for the 统一资源定位器(URL) property
* @param value the new value for the 统一资源定位器(URL) property
*/
public void setDbUser(java.lang.String value){
this.dbUser = value;
}
/*****************************************************************************
* Set method for the 驱动程序 property
* @param value the new value for the 驱动程序 property
*/
public void setDriver(java.lang.String value){
this.driver = value;
}
/*****************************************************************************
* Set method for the 统一资源定位器(URL) property
* @param value the new value for the 统一资源定位器(URL) property
*/
public void setDsName(java.lang.String value){
this.dsName = value;
}
/*****************************************************************************
* Set method for the 统一资源定位器(URL) property
* @param value the new value for the 统一资源定位器(URL) property
*/
public void setPassWord(java.lang.String value){
this.passWord = value;
}
/*****************************************************************************
* Set method for the 统一资源定位器(URL) property
* @param value the new value for the 统一资源定位器(URL) property
*/
public void setURL(/tech-qa-java/java.lang.String value){
this.URL = value;
}
/*****************************************************************************
* Set method for the 统一资源定位器(URL) property
* @param value the new value for the 统一资源定位器(URL) property
*/
public void setUserName(java.lang.String value){
this.userName = value;
}
/**
* 在此处插入方法说明。
* 创建日期:(2001-1-6 14:37:21)
*/
public void siteStatus(Connection conn)
{
String areaId = new String();
String tempAreaId = this.areaId;
int areaLength = 0;
String brc = this.tellerId.substring(0,4);
String siteId="", siteName="",siteX="", siteY="", atmid="";
if(conn!=null)
{
try
{
java.sql.Statement st1 = conn.createStatement(),st2 = conn.createStatement();
ResultSet rs1, rs2;
String sqle, sqle1, sqle2;
String box1status="", box2status="", box3status="", box4status="", box5status="", box6status=""; //钞箱状态
String readerstatus="", prjstatus="", prrstatus="", depstatus="", cdmstatus="";
// 读卡器 日志 凭条 存款模块 取款模块
String demstatus="", pcbstatus="", linestatus="", servicestatus="", troublecode="";
// 加密 控制 线路 服务
int siteStatus=0;
int siteNo=0;
if (tempAreaId.equals("0000")) //若管理区域为全部,则取该区域所有SITE码
{
sqle="SELECT DISTINCT siteID FROM atmSiteCode WHERE brc='" + brc + "'";
rs1=st1.executeQuery(sqle);
tempAreaId = "";
while (rs1.next())
{
tempAreaId = tempAreaId + rs1.getString("SiteId");
}
}
areaLength = tempAreaId.length();
sitesStatus = new String[2][areaLength/4];
for(int i=0; i
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
站内导航:
特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!