webapp.java


  Web アプリケーションの為の Beans




作成場所
  

C:\Webhost\tomcat5.5\WEB-INF\classes\lightbox
  

webapp.class 作成サンプル (バッチファイル)
  

javac
 -classpath
 "..\;C:\Tomcat5.5\common\lib\servlet-api.jar;C:\Tomcat5.5\common\lib\jsp-api.jar"
 webapp.java
 -Xlint:unchecked 
  

  

package lightbox;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.util.*;
import java.io.*;
import java.sql.*;

public class webapp {

	private Hashtable hashRequest = null;
	public ServletContext application = null;
	public String appName = "";
	private String debug = "";

	// *****************************************************
	// GNO チェック
	// *****************************************************
	public boolean GNO( HttpServletRequest HttpRequest, String Target ) {

		return request( HttpRequest, "GNO" ).equals( Target );

	}

	// *****************************************************
	// エラーチェック
	// *****************************************************
	public boolean ERROR( ) {

		return !get( "ErrMessage" ).equals( "" );

	}

	// *****************************************************
	// 入力初期化
	// *****************************************************
	public void Initialize( HttpServletRequest request ) {

		Enumeration enumData;
		Enumeration enumInit;
		String strName;
		String strData;

		if ( hashRequest == null ) {
			hashRequest = new Hashtable();
		}

		// プログラム固有内部変数のクリア
		clear();

		enumData = request.getParameterNames();
		while( enumData.hasMoreElements() ) {
			strName = enumData.nextElement().toString();
			strData = toShiftjis( request.getParameter( strName ) );
			set( strName, strData );
		}

		enumInit = application.getInitParameterNames();
		while( enumInit.hasMoreElements() ) {
			strName = enumInit.nextElement().toString();
			setApplication(
				strName, application.getInitParameter(strName)
			);
		}

	}

	// *****************************************************
	// リクエスト取得
	// *****************************************************
	public String request( HttpServletRequest request, String key ) {

		if ( request.getParameter( key ) == null ) {
			return "";
		}
		
		return request.getParameter( key );

	}

	// *****************************************************
	// 第2パス入力データ埋め込み
	// *****************************************************
	public void createIndata( ) {

		String key;
		String key2;
		int nLen;

		Enumeration enumData;
		enumData = hashRequest.keys();
		while( enumData.hasMoreElements() ) {
		  key = enumData.nextElement().toString();
		  nLen = str_len( appName );
		  if ( str_substr( key, 0, nLen ).equals( appName ) ) {
		    if ( str_substr( key, nLen+1, 2 ).equals( "In" ) ) {
		      if ( !str_substr( key, nLen+1, 3 ).equals( "In2" ) ) {
		        key2 = str_substr( key, nLen+1, 50 );
		        setAdd( "PassData", "<INPUT type=hidden name=" );
		        setAdd( "PassData", key2 );
		        setAdd( "PassData", " value=\"" );
		        setAdd( "PassData", get( key2 ) );
		        setAdd( "PassData", "\">\n" );
		      }
		    }
		  }
		}

	}

	// *****************************************************
	// デバッグ用表示 ( getProperty 用 )
	// *****************************************************
	public String getDebug() {

		String strName;
		String ret = "";
		String Work= "";

		Set KeySet = hashRequest.keySet();
		Object KeyArray[] = KeySet.toArray();
		Arrays.sort( KeyArray );

		ret = "<TABLE border=0 cellpadding=5 cellspacing=1 bgcolor=black>\n";
		ret += "<TH bgcolor=silver>Keys</TH><TH bgcolor=silver>Values</TH>\n";
		for( int i = 0 ; i < KeyArray.length; i++ ) {
			strName = KeyArray[i].toString();
			if ( !strName.equals( appName + "_PassData" ) ) {
				ret += "<TR>";
				ret += "<TD bgcolor=white>" + strName + "</TD>";
				ret += "<TD bgcolor=white>"
					+ hashRequest.get( strName ) + "</TD>";
				ret += "</TR>\n";
			}
		}
		ret = ret + "</TABLE>\n";

		return ret;

	}
	public void DispData( JspWriter out )
		throws java.io.IOException, ServletException {
		out.println( getDebug() );
	}
	public void DispDebug( HttpServletRequest request, JspWriter out )
		throws java.io.IOException, ServletException {
		if ( request.getParameter( "mode" ) == null ) {
			return;
		}
		if ( request.getParameter( "mode" ).equals( "debug" ) ) {
			out.println( getDebug() );
		}
	}

	// *****************************************************
	// オブジェクト取り出し
	// *****************************************************
	public Object ObjectGet( Object key ) {

		Object ret;

		if ( hashRequest == null ) {
			hashRequest = new Hashtable();
		}

		if ( hashRequest.get( appName + "_" + key ) != null ) {
			ret = hashRequest.get( appName + "_" + key );
		}
		else {
			ret = "";
		}

		return ret;

	}

	// *****************************************************
	// プログラム固有内部変数登録
	// *****************************************************
	public void set( Object key, Object value ) {

		put( key, value );

	}
	// *****************************************************
	// プログラム固有内部変数登録
	// *****************************************************
	public void put( Object key, Object value ) {

		if ( hashRequest == null ) {
			hashRequest = new Hashtable();
		}

		hashRequest.put( appName + "_" + key, value );

	}
	// *****************************************************
	// プログラム固有内部変数に追加
	// *****************************************************
	public void setAdd( Object key, Object value ) {

		String Work = get( key );

		Work += value;
		put( key, Work );

	}
	// *****************************************************
	// プログラム固有内部取り出し
	// *****************************************************
	public String get( Object key ) {

		String ret;

		if ( hashRequest == null ) {
			hashRequest = new Hashtable();
		}

		if ( hashRequest.get( appName + "_" + key ) != null ) {
			ret = hashRequest.get( appName + "_" + key ).toString();
		}
		else {
			ret = "";
		}

		return ret;

	}

	// *****************************************************
	// アプリケーション変数登録
	// *****************************************************
	public void setApplication( Object key, Object value ) {

		if ( hashRequest == null ) {
			hashRequest = new Hashtable();
		}

		if ( value == null ) {
			hashRequest.put( "APPLICATION_" + key, "" );
		}
		else {
			hashRequest.put( "APPLICATION_" + key, value );
		}

	}
	// *****************************************************
	// アプリケーション変数取り出し
	// *****************************************************
	public String getApplication( Object key ) {

		String ret;

		if ( hashRequest == null ) {
			hashRequest = new Hashtable();
		}

		if ( hashRequest.get( "APPLICATION_" + key ) != null ) {
			ret = hashRequest.get( "APPLICATION_" + key ).toString();
		}
		else {
			ret = "";
		}

		return ret;

	}
	// *****************************************************
	// セッョン変数登録
	// *****************************************************
	public void setSession( Object key, Object value ) {

		putSession( key, value );

	}
	// *****************************************************
	// セッョン変数登録
	// *****************************************************
	public void putSession( Object key, Object value ) {

		if ( hashRequest == null ) {
			hashRequest = new Hashtable();
		}

		hashRequest.put( "SESSION_" + key, value );

	}
	// *****************************************************
	// セッョン変数取り出し
	// *****************************************************
	public String getSession( Object key ) {

		String ret;

		if ( hashRequest == null ) {
			hashRequest = new Hashtable();
		}

		if ( hashRequest.get( "SESSION_" + key ) != null ) {
			ret = hashRequest.get( "SESSION_" + key ).toString();
		}
		else {
			ret = "";
		}

		return ret;

	}

	// *****************************************************
	// 取り出し2
	// *****************************************************
	public String getAppData( Object key ) {

		String ret;

		if ( hashRequest == null ) {
			hashRequest = new Hashtable();
		}

		if ( hashRequest.get( key ) != null ) {
			ret = hashRequest.get( key ).toString();
		}
		else {
			ret = "";
		}

		return ret;

	}

	// *****************************************************
	// プログラム固有内部変数のクリア
	// *****************************************************
	public void clear( ) {

		if ( hashRequest == null ) {
			hashRequest = new Hashtable();
		}

		String strKey;
		String strAppName;

		Set KeySet = hashRequest.keySet();
		Object KeyArray[] = KeySet.toArray();
		Arrays.sort( KeyArray );

		for( int i = 0 ; i < KeyArray.length; i++ ) {
			strKey = KeyArray[i].toString();
			try {
				strAppName = strKey.substring( 0, appName.length() );
				if ( strAppName.equals( appName ) ) {
					hashRequest.remove( strKey );
				}
			}
			catch ( IndexOutOfBoundsException  e ) {
			}
		}

	}

	// *****************************************************
	// セッション内部変数のクリア
	// *****************************************************
	public void clearSession( ) {

		if ( hashRequest == null ) {
			hashRequest = new Hashtable();
		}

		String strKey;
		String strWork;

		Set KeySet = hashRequest.keySet();
		Object KeyArray[] = KeySet.toArray();
		Arrays.sort( KeyArray );

		for( int i = 0 ; i < KeyArray.length; i++ ) {
			strKey = KeyArray[i].toString();
			try {
				strWork = strKey.substring( 0, 7 );
				if ( strWork.equals( "SESSION" ) ) {
					hashRequest.remove( strKey );
				}
			}
			catch ( IndexOutOfBoundsException  e ) {
			}
		}

	}

	// *****************************************************
	// 全ての内部変数をクリア
	// *****************************************************
	public void clearAll( ) {

		if ( hashRequest == null ) {
			hashRequest = new Hashtable();
		}

		hashRequest.clear();
	}

	// *****************************************************
	// ServletContext 保存
	// *****************************************************
	public void startApplication( ServletContext app, String curName ) {

		application = app;
		appName = curName;
		application.log( "--------------------------------" );
		application.log( "プログラム開始 : " + appName );

	}

	// *****************************************************
	// LOG
	// *****************************************************
	public void log( String Message ) {

		application.log( "-- " + appName + " : " + Message );

	}

	// *****************************************************
	// フォームから受け取った文字列が、ISO_8859_1でデコード
	// されてしまったているので、文字列を元へ戻す為に、いっ
	// たんISO_8859_1でエンコードし、それを再びShift_JISで
	// デコードする
	// *****************************************************
	public String toShiftjis( String strData ) {

		String ret;

		if ( strData != null ) {
			try {
				ret = new String( 
					strData.getBytes( "ISO_8859_1" ),
					 "Shift_JIS"
				);
			}
			catch( UnsupportedEncodingException e ) {
				ret = "UnsupportedEncoding";
			}
		}
		else {
			ret = "";
		}

		return ret;

	}

	// *****************************************************
	// 文字列比較
	// *****************************************************
	public boolean cmp( String key, String value ) {

		return str_cmp( get( key ), value );
	}
	public boolean str_cmp( String s1, String s2 ) {

		return s1.equals( s2 );
	}
	public boolean cmpi( String key, String value ) {

		return str_cmpi( get( key ), value );
	}
	public boolean str_cmpi( String s1, String s2 ) {

		return s1.equalsIgnoreCase( s2 );
	}

	// *****************************************************
	// 加工
	// *****************************************************
	public String lower( String key ) {

		return str_lower( get( key ) );

	}
	public String str_lower( String value ) {

		return value.toLowerCase();

	}
	public String upper( String key ) {

		return str_upper( get( key ) );

	}
	public String str_upper( String value ) {

		return value.toUpperCase();

	}
	public int atoi( String key ) {

		return str_atoi( get( key ) );

	}
	public int str_atoi( String value ) {

		return Integer.parseInt( value );

	}
	public String itoa( int value ) {

		return Integer.toString( value );

	}
	public String trim( String key ) {

		return str_trim( get( key ) );

	}
	public String str_trim( String value ) {

		return value.trim();

	}
	public String substr( String key, int start, int len ) {

		return str_substr( get( key ), start, len );

	}
	public String str_substr( String value, int start, int len ) {

		if ( start+len > str_len( value ) ) {
			return value.substring( start, str_len( value ) );
		}
		else {
			return value.substring( start, start+len );
		}

	}
	public String str_replace( String value, String target, String rpl ) {

		int pos = 0;
		int next = 0;
		String strRet = "";

		next = value.indexOf( target, pos );
		if ( next == -1 ) {
			return value;
		}

		while( next != -1 ) {
			strRet += value.substring( pos, next );
			strRet += rpl;
			pos = next + str_len( target );

			next = value.indexOf( target, pos );
		}

		if ( pos != str_len( value ) ) {
			strRet += str_substr( value, pos, str_len( value ) - pos );
		}

		return strRet;

	}

	// *****************************************************
	// 情報
	// *****************************************************
	public int len( String key ) {

		return str_len( get( key ) );

	}
	public int str_len( String value ) {

		return value.length();

	}
	public boolean find( String key, String target ) {

		return str_find( get( key ), target );

	}
	public boolean str_find( String value, String target ) {

		int pos;

		pos = value.indexOf( target );
		if ( pos == -1 ) {
			return false;
		}
		else {
			return true;
		}
	}
	public boolean find( int start, String key, String target ) {

		return str_find( start, get( key ), target );

	}
	public boolean str_find( int start, String value, String target ) {

		int pos;

		pos = value.indexOf( target, start );
		if ( pos == -1 ) {
			return false;
		}
		else {
			return true;
		}
	}

	// *****************************************************
	// トークン
	// *****************************************************
	public void token( String key, String value, String delim ) {
		Hashtable hashToken = new Hashtable();
		int nCount = 0;

		StringTokenizer st = new StringTokenizer( value, delim );
		while (st.hasMoreTokens()) {
			hashToken.put( nCount, st.nextToken() );
			nCount++;
		}

		set( key, hashToken );
	}
	public int tokencount( String key ) {

		return ((Hashtable)ObjectGet( key )).size();

	}
	public String tokenget( String key, int nIndex ) {

		if ( nIndex < 0 ) {
			return null;
		}
		if ( nIndex >= tokencount( key ) ) {
			return null;
		}

		return ((Hashtable)ObjectGet( key )).get( nIndex ).toString();

	}

}
  







  文字列比較

  

// *****************************************************
// 文字列比較
// *****************************************************
public boolean cmp( String key, String value ) {

	return str_cmp( get( key ), value );
}
public boolean str_cmp( String s1, String s2 ) {

	return s1.equals( s2 );
}
public boolean cmpi( String key, String value ) {

	return str_cmpi( get( key ), value );
}
public boolean str_cmpi( String s1, String s2 ) {

	return s1.equalsIgnoreCase( s2 );
}
  

  大文字小文字変換

  

// *****************************************************
//
// *****************************************************
public String lower( String key ) {

	return str_lower( get( key ) );

}
public String str_lower( String value ) {

	return value.toLowerCase();

}
public String upper( String key ) {

	return str_upper( get( key ) );

}
public String str_upper( String value ) {

	return value.toUpperCase();

}
  

  文字列数値変換

  

// *****************************************************
//
// *****************************************************
public int atoi( String key ) {

	return str_atoi( get( key ) );

}
public int str_atoi( String value ) {

	return Integer.parseInt( value );

}
public String itoa( int value ) {

	return Integer.toString( value );

}
  

  スペース削除

  

// *****************************************************
//
// *****************************************************
public String trim( String key ) {

	return str_trim( get( key ) );

}
public String str_trim( String value ) {

	return value.trim();

}
  

  部分文字列

  

// *****************************************************
//
// *****************************************************
public String substr( String key, int start, int len ) {

	return str_substr( get( key ), start, len );

}
public String str_substr( String value, int start, int len ) {

	if ( start+len > str_len( value ) ) {
		return value.substring( start, str_len( value ) );
	}
	else {
		return value.substring( start, start+len );
	}

}
  

  文字列置換

  

// *****************************************************
//
// *****************************************************
public String str_replace( String value, String target, String rpl ) {

	int pos = 0;
	int next = 0;
	String strRet = "";

	next = value.indexOf( target, pos );
	if ( next == -1 ) {
		return value;
	}

	while( next != -1 ) {
		strRet += value.substring( pos, next );
		strRet += rpl;
		pos = next + str_len( target );

		next = value.indexOf( target, pos );
	}

	if ( pos != str_len( value ) ) {
		strRet += str_substr( value, pos, str_len( value ) - pos );
	}

	return strRet;

}
  

  文字列検索

  

// *****************************************************
//
// *****************************************************
public boolean find( String key, String target ) {

	return str_find( get( key ), target );

}
public boolean str_find( String value, String target ) {

	return str_find( 0, value, target );

}
public boolean find( int start, String key, String target ) {

	return str_find( start, get( key ), target );

}
public boolean str_find( int start, String value, String target ) {

	int pos;

	pos = value.indexOf( target, start );
	if ( pos == -1 ) {
		return false;
	}
	else {
		return true;
	}
}
  

  文字列長

  

// *****************************************************
//
// *****************************************************
public int len( String key ) {

	return str_len( get( key ) );

}
public int str_len( String value ) {

	return value.length();

}
  

  トークン

内部特別変数エリア ( ハッシュテーブル ) の一つとしてトークンを保持したハッシュテーブル
を登録する。

  

// *****************************************************
// トークン
// *****************************************************
public void token( String key, String value, String delim ) {
	Hashtable hashToken = new Hashtable();
	int nCount = 0;

	StringTokenizer st = new StringTokenizer( value, delim );
	while (st.hasMoreTokens()) {
		hashToken.put( nCount, st.nextToken() );
		nCount++;
	}

	set( key, hashToken );
}
public int tokencount( String key ) {

	return ((Hashtable)ObjectGet( key )).size();

}
public String tokenget( String key, int nIndex ) {

	if ( nIndex < 0 ) {
		return null;
	}
	if ( nIndex >= tokencount( key ) ) {
		return null;
	}

	return ((Hashtable)ObjectGet( key )).get( nIndex ).toString();

}
  

  SHIFT_JIS 変換

フォームから受け取った文字列が、ISO_8859_1 でデコードされてしまったているので、
文字列を元へ戻す為に、いったん ISO_8859_1 でエンコードし、それを再び Shift_JISで
デコードする

  

// *****************************************************
//
// *****************************************************
public String toShiftjis( String strData ) {

	String ret;

	if ( strData != null ) {
		try {
			ret = new String( 
				strData.getBytes( "ISO_8859_1" ),
				 "Shift_JIS"
			);
		}
		catch( UnsupportedEncodingException e ) {
			ret = "UnsupportedEncoding";
		}
	}
	else {
		ret = "";
	}

	return ret;

}
  

  アプリケーション開始

1) ServletContext を保存。
2) control.jsp 単位にアプリケーション ID を指定して保存する。
3) 開始ログを出力

  

// *****************************************************
//
// *****************************************************
public void startApplication( ServletContext app, String curName ) {

	application = app;
	appName = curName;
	application.log( "--------------------------------" );
	application.log( "プログラム開始 : " + appName );

}
  

  ログ出力

logs\stdout.log に出力

  

// *****************************************************
//
// *****************************************************
public void log( String Message ) {

	application.log( "-- " + appName + " : " + Message );

}
  

  雛形専用

ヘッダー画面よりボディ画面に FORM の TARGET 属性で送る時に、ボディ画面にヘッダー画面の
入力項目を HIDDEN で埋め込む

  

// *****************************************************
//  第2パス入力データ埋め込み
// *****************************************************
public void createIndata( ) {

	String key;
	String key2;
	int nLen;

	Enumeration enumData;
	enumData = hashRequest.keys();
	while( enumData.hasMoreElements() ) {
	  key = enumData.nextElement().toString();
	  nLen = str_len( appName );
	  if ( str_substr( key, 0, nLen ).equals( appName ) ) {
	    if ( str_substr( key, nLen+1, 2 ).equals( "In" ) ) {
	      if ( !str_substr( key, nLen+1, 3 ).equals( "In2" ) ) {
	        key2 = str_substr( key, nLen+1, 50 );
	        setAdd( "PassData", "<INPUT type=hidden name=" );
	        setAdd( "PassData", key2 );
	        setAdd( "PassData", " value=\"" );
	        setAdd( "PassData", get( key2 ) );
	        setAdd( "PassData", "\">\n" );
	      }
	    }
	  }
	}

}
  

  

// *****************************************************
// GNO チェック
// *****************************************************
public boolean GNO( HttpServletRequest HttpRequest, String Target ) {

	return request( HttpRequest, "GNO" ).equals( Target );

}

// *****************************************************
// エラーチェック
// *****************************************************
public boolean ERROR( ) {

	return !get( "ErrMessage" ).equals( "" );

}
  

  リクエスト取得

フレームを使用している場合同時に二つの画面を表示する為、内部変数より入力項目を取得すると
後書きのデータを取得してしまうので直接リクエストデータより値を取得

  

// *****************************************************
//
// *****************************************************
public String request( HttpServletRequest request, String key ) {

	if ( request.getParameter( key ) == null ) {
		return "";
	}
	
	return request.getParameter( key );

}
  

  入力初期化

リクエストデータを内部 Hashtable に全て保存する

内部変数には、3種類の仕様がある
1) リクエスト毎にクリアされる プログラム変数
2) セッションで保存される セッション変数
3) アプリケーション全体で一定の アプリケーション変数

ここでは、リクエストより取得されるプログラム変数と web.xml より取得される
アプリケーション変数を設定する

  

// *****************************************************
//
// *****************************************************
public void Initialize( HttpServletRequest request ) {

	Enumeration enumData;
	Enumeration enumInit;
	String strName;
	String strData;

	if ( hashRequest == null ) {
		hashRequest = new Hashtable();
	}

	// プログラム固有内部変数のクリア
	clear();

	enumData = request.getParameterNames();
	while( enumData.hasMoreElements() ) {
		strName = enumData.nextElement().toString();
		strData = toShiftjis( request.getParameter( strName ) );
		set( strName, strData );
	}

	enumInit = application.getInitParameterNames();
	while( enumInit.hasMoreElements() ) {
		strName = enumInit.nextElement().toString();
		setApplication(
			strName, application.getInitParameter(strName)
		);
	}

}
  

  プログラム変数

  

// *****************************************************
// プログラム固有内部変数登録
// *****************************************************
public void set( Object key, Object value ) {

	put( key, value );

}
// *****************************************************
// プログラム固有内部変数登録
// *****************************************************
public void put( Object key, Object value ) {

	if ( hashRequest == null ) {
		hashRequest = new Hashtable();
	}

	hashRequest.put( appName + "_" + key, value );

}
// *****************************************************
// プログラム固有内部変数に追加
// *****************************************************
public void setAdd( Object key, Object value ) {

	String Work = get( key );

	Work += value;
	put( key, Work );

}
// *****************************************************
// プログラム固有内部取り出し
// *****************************************************
public String get( Object key ) {

	String ret;

	if ( hashRequest == null ) {
		hashRequest = new Hashtable();
	}

	if ( hashRequest.get( appName + "_" + key ) != null ) {
		ret = hashRequest.get( appName + "_" + key ).toString();
	}
	else {
		ret = "";
	}

	return ret;

}
// *****************************************************
// プログラム固有内部変数のクリア
// *****************************************************
public void clear( ) {

	if ( hashRequest == null ) {
		hashRequest = new Hashtable();
	}

	String strKey;
	String strAppName;

	Set KeySet = hashRequest.keySet();
	Object KeyArray[] = KeySet.toArray();
	Arrays.sort( KeyArray );

	for( int i = 0 ; i < KeyArray.length; i++ ) {
		strKey = KeyArray[i].toString();
		try {
			strAppName = strKey.substring( 0, appName.length() );
			if ( strAppName.equals( appName ) ) {
				hashRequest.remove( strKey );
			}
		}
		catch ( IndexOutOfBoundsException  e ) {
		}
	}

}
  

  セッション変数

  

// *****************************************************
// セッョン変数登録
// *****************************************************
public void setSession( Object key, Object value ) {

	putSession( key, value );

}
// *****************************************************
// セッョン変数登録
// *****************************************************
public void putSession( Object key, Object value ) {

	if ( hashRequest == null ) {
		hashRequest = new Hashtable();
	}

	hashRequest.put( "SESSION_" + key, value );

}
// *****************************************************
// セッョン変数取り出し
// *****************************************************
public String getSession( Object key ) {

	String ret;

	if ( hashRequest == null ) {
		hashRequest = new Hashtable();
	}

	if ( hashRequest.get( "SESSION_" + key ) != null ) {
		ret = hashRequest.get( "SESSION_" + key ).toString();
	}
	else {
		ret = "";
	}

	return ret;

}
// *****************************************************
// セッション内部変数のクリア
// *****************************************************
public void clearSession( ) {

	if ( hashRequest == null ) {
		hashRequest = new Hashtable();
	}

	String strKey;
	String strWork;

	Set KeySet = hashRequest.keySet();
	Object KeyArray[] = KeySet.toArray();
	Arrays.sort( KeyArray );

	for( int i = 0 ; i < KeyArray.length; i++ ) {
		strKey = KeyArray[i].toString();
		try {
			strWork = strKey.substring( 0, 7 );
			if ( strWork.equals( "SESSION" ) ) {
				hashRequest.remove( strKey );
			}
		}
		catch ( IndexOutOfBoundsException  e ) {
		}
	}

}
  

  アプリケーション変数

  

// *****************************************************
// アプリケーション変数登録
// *****************************************************
public void setApplication( Object key, Object value ) {

	if ( hashRequest == null ) {
		hashRequest = new Hashtable();
	}

	if ( value == null ) {
		hashRequest.put( "APPLICATION_" + key, "" );
	}
	else {
		hashRequest.put( "APPLICATION_" + key, value );
	}

}
// *****************************************************
// アプリケーション変数取り出し
// *****************************************************
public String getApplication( Object key ) {

	String ret;

	if ( hashRequest == null ) {
		hashRequest = new Hashtable();
	}

	if ( hashRequest.get( "APPLICATION_" + key ) != null ) {
		ret = hashRequest.get( "APPLICATION_" + key ).toString();
	}
	else {
		ret = "";
	}

	return ret;

}
  

  全ての内部変数をクリア

  

// *****************************************************
//
// *****************************************************
public void clearAll( ) {

	if ( hashRequest == null ) {
		hashRequest = new Hashtable();
	}

	hashRequest.clear();
}
  

  直接指定の内部変数取得

  

// *****************************************************
//
// *****************************************************
public String getAppData( Object key ) {

	String ret;

	if ( hashRequest == null ) {
		hashRequest = new Hashtable();
	}

	if ( hashRequest.get( key ) != null ) {
		ret = hashRequest.get( key ).toString();
	}
	else {
		ret = "";
	}

	return ret;

}
  

  オブジェクト取り出し

通常、内部変数は文字列で処理するが、Object として保存できるので、
それを Object として取得する為に使用する

  

// *****************************************************
//
// *****************************************************
public Object ObjectGet( Object key ) {

	Object ret;

	if ( hashRequest == null ) {
		hashRequest = new Hashtable();
	}

	if ( hashRequest.get( appName + "_" + key ) != null ) {
		ret = hashRequest.get( appName + "_" + key );
	}
	else {
		ret = "";
	}

	return ret;

}
  

  デバッグ用表示

  

内部変数の一覧を表示する。getDebug メソッドは jsp タグで記述できる

<jsp:getProperty name="my" property="debug" />
  

  

// *****************************************************
//
// *****************************************************
public String getDebug() {

	String strName;
	String ret = "";
	String work;

	Set KeySet = hashRequest.keySet();
	Object KeyArray[] = KeySet.toArray();
	Arrays.sort( KeyArray );

	ret = "<TABLE border=0 cellpadding=5 cellspacing=1 bgcolor=black>\n";
	ret += "<TH bgcolor=silver>Keys</TH><TH bgcolor=silver>Values</TH>\n";
	for( int i = 0 ; i < KeyArray.length; i++ ) {
		strName = KeyArray[i].toString();
		if ( !strName.equals( appName + "_PassData" ) ) {
			ret += "<TR>";
			ret += "<TD bgcolor=white>" + strName + "</TD>";
			work = (String)hashRequest.get( strName );
			work = str_replace( work, "<", "&lt;" );
			work = str_replace( work, ">", "&gt;" );
			ret += "<TD bgcolor=white>"
				+ work + "</TD>";
			ret += "</TR>\n";
		}
	}
	ret = ret + "</TABLE>\n";

	return ret;

}
public void DispData( JspWriter out )
	throws java.io.IOException, ServletException {
	out.println( getDebug() );
}
public void DispDebug( HttpServletRequest request, JspWriter out )
	throws java.io.IOException, ServletException {
	if ( request.getParameter( "mode" ) == null ) {
		return;
	}
	if ( request.getParameter( "mode" ).equals( "debug" ) ) {
		out.println( getDebug() );
	}
}
  




yahoo  google  MSDN  MSDN(us)  WinFAQ  Win Howto  tohoho  ie_DHTML  vector  wdic  辞書  天気 


[jsp]
Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
24/04/20 17:29:41
InfoBoard Version 1.00 : Language=Perl

1 BatchHelper COMprog CommonSpec Cprog CprogBase CprogSAMPLE CprogSTD CprogSTD2 CprogWinsock Cygwin GameScript HTML HTMLcss InstallShield InstallShieldFunc JScript JScriptSAMPLE Jsfuncs LLINK OldProg OracleGold OracleSilver PRO PRObrowser PROc PROconePOINT PROcontrol PROftpclient PROjscript PROmailer PROperl PROperlCHAT PROphp PROphpLesson PROphpLesson2 PROphpLesson3 PROphpfunction PROphpfunctionArray PROphpfunctionMisc PROphpfunctionString PROsql PROvb PROvbFunction PROvbString PROvbdbmtn PROvbonepoint PROwebapp PROwin1POINT PROwinSYSTEM PROwinYOROZU PROwindows ProjectBoard RealPHP ScriptAPP ScriptMaster VBRealtime Vsfuncs a1root access accreq adsi ajax amazon argus asp aspSample aspVarious aspdotnet aw2kinst cappvariety centura ckeyword classStyle cmaterial cmbin cmdbapp cmenum cmlang cmlistbox cmstd cmstdseed cmtxt cs daz3d db dbCommon dbaccess dnettool dos download flex2 flex3 flex4 framemtn framereq freeWorld freesoft gimp ginpro giodownload google hdml home hta htmlDom ie9svg install java javaSwing javascript jetsql jquery jsp jspTest jspVarious lightbox listasp listmsapi listmsie listmsiis listmsnt listmspatch listmsscript listmsvb listmsvc memo ms msde mysql netbeans oraPlsql oracle oracleWiper oraclehelper orafunc other panoramio pear perl personal pgdojo pgdojo_cal pgdojo_holiday pgdojo_idx pgdojo_ref pgdojo_req php phpVarious phpguide plsql postgres ps r205 realC realwebapp regex rgaki ruby rule sboard sc scprint scquest sdb sdbquest seesaa setup sh_Imagick sh_canvas sh_dotnet sh_google sh_tool sh_web shadowbox shgm shjquery shvbs shweb sjscript skadai skywalker smalltech sperl sqlq src systemdoc tcpip tegaki three toolbox twitter typeface usb useXML vb vbdb vbsfunc vbsguide vbsrc vpc wcsignup webanymind webappgen webclass webparts webtool webwsh win8 winofsql wmi work wp youtube