package ui;
import java.io.Serializable;
import javax.swing.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
// Import the NamveValue model
import jspstyle.*;
import java.util.HashMap;
/**
* Class to provide page flow logic for the Data Source Explorer.
* All requests go to this class. This class is responsible for
* instantiating the beans required by the system.
* This class uses reflection to instantiate request handlers as
* required.
*/
public class RequestController implements Serializable {
//---------------------------------------------------------------------
// Class data and methods
//---------------------------------------------------------------------
/**
* URL of the system's login page.
* We'll redirect users to this if they don't have a connection
*/
public static final String LOGIN_PAGE = "login.html";
/** Package from which to attempt to load RequestHandler objects */
private static final String REQUEST_HANDLER_PACKAGE = "ui.requesthandlers";
/**
* Name of the session bean that will be used for this application.
* This must be matched by the useBean actions in the JSPs.
*/
private static final String SESSION_BEAN_NAME = "browseSession";
/**
* Convenience method for RequestHandler implementations, allowing Java classes to access
* the session bean easily. Unlike checkSessionBeanIsAvailable(), this method will
* throw an exception if the bean has not already been instantiated.
* @return the session bean, which must have been instantiated already.
*/
public static BrowseSession FindSessionBean(PageContext pageContext, RequestHandler rh) throws BrowseException {
BrowseSession session = (BrowseSession) pageContext.getAttribute(RequestController.SESSION_BEAN_NAME, PageContext.SESSION_SCOPE);
if (session == null)
throw new BrowseException("Internal error: illegal state. Session bean shouldn't be null handling action " + rh.getClass());
return session;
}
//---------------------------------------------------------------------
// Instance data
//---------------------------------------------------------------------
/**
* Hash table of RequestHandler instances, keyed by class name.
* This is used for performance optimization, to avoid the need
* to load a class by name to process each request.
*/
private HashMap handlerHash = new HashMap();
//---------------------------------------------------------------------
// Public methods
//---------------------------------------------------------------------
/**
* This is the key method through which all request to the
* application are sent.
* Process a request, updating the session and
* returning the URL of the resulting JSP view
*/
public String getNextPage(PageContext pageContext, HttpServletRequest request) throws BrowseException {
String action = request.getParameter("action");
// If no action was specified, the user must first log in
if (action == null || action.equals(""))
return LOGIN_PAGE;
// If we have an action parameter, obtain the RequestHandler that implements
// the action. This method will throw a BrowseException if no handler is
// associated with the action.
RequestHandler requestHandler = getHandlerInstance(action);
// Create the session bean if it doesn't exist
checkSessionBeanIsAvailable(pageContext);
// Return the URL of the view the RequestHandler instance
// chooses after doing the work of processing the request
return requestHandler.handleRequest(pageContext, request);
} // getNextPage
/**
* Locate and return the RequestHandler instance for this action.
* Instances are stored in a hash table once instantiated, so after the initial
* use of Class.forName() this method is very fast and does not rely on
* reflection.
*/
private RequestHandler getHandlerInstance(String action) throws BrowseException {
String handlerName = REQUEST_HANDLER_PACKAGE + "." + action;
RequestHandler requestHandler = (RequestHandler) handlerHash.get(handlerName);
if (requestHandler == null) {
// We don't have a handler instance associated with this action,
// so we need to instantiate one and put in in our hash table
try {
System.out.println("Loading handler instance...");
// Use reflection to load the class by name
Class handlerClass = Class.forName(handlerName);
// Check the class we obtained implements the RequestHandler interface
if (!RequestHandler.class.isAssignableFrom(handlerClass))
throw new BrowseException("Class " + handlerName + " does not implement the RequestHandler interface " );
// Instantiate the request handler object
requestHandler = (RequestHandler) handlerClass.newInstance();
// Save the instance so we don't have to load it dynamically to process
// further requests from this user
handlerHash.put(handlerName, requestHandler);
}
catch (ClassNotFoundException ex) {
throw new BrowseException("No handler for action [" + handlerName
+ "]: class " + handlerName + " could not be loaded. " + ex);
}
catch (InstantiationException ex) {
// It probably doesn't have a no-argument constructor
throw new BrowseException("Class "+ handlerName + " could not be instantiated. "
+ " Is it a bean? " + ex);
}
catch (IllegalAccessException ex) {
throw new BrowseException("Class " + handlerName + " could not be instantiated. "
+ "Does it have a public constructor? " + ex);
}
}
// If we get to here, we have a valid RequestHandler instance,
// whether it came from the hash table or from dynamical class loading
return requestHandler;
} // getHandlerInstance
//---------------------------------------------------------------------
// Implementation methods
//---------------------------------------------------------------------
/**
* Return the user's session bean. Instantiate a new session bean and
* put it in the session if none is found.
*/
private void checkSessionBeanIsAvailable(PageContext pageContext) {
BrowseSession session = (BrowseSession)
pageContext.getAttribute(SESSION_BEAN_NAME, PageContext.SESSION_SCOPE);
if (session == null) {
System.out.println("RequestController: creating session object");
session = new BrowseSession();
// Place the session in the PageContext, so it will be accessible
// to JSPs as a session bean
pageContext.setAttribute(SESSION_BEAN_NAME, session, PageContext.SESSION_SCOPE);
}
}
} // class RequestController
没有合适的资源?快使用搜索试试~ 我知道了~
jsp基于Web的可维护的数据库浏览器(源代码)
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共69个文件
java:34个
class:18个
jsp:10个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
需积分: 1 0 下载量 138 浏览量
2024-05-21
16:20:47
上传
评论
收藏 167KB ZIP 举报
温馨提示
可维护的数据库浏览器,采用基于Web的多层应用模型。程序上采用MVC结构,可以将数据存取逻辑与数据表现逻辑分开,组合JSP Servlet和JavaBean来建造灵活与可维护的应用程序的设计模式。 Web界面的要求是允许用户浏览相关数据库中的内容.该界面使用户可以通过指定一个JDBC驱动器或URL来与一个数据库连接。接着,应用程序会允许用户浏览数据库中定义的所有表,并且可以选择任何一个表对其数据进行处理。同样,用户还可以输入SQL查询语句并查看这些查询操作产生的列表数据。在用户使用会话的任何时间内,必须确保用户可以很容易地断开数据库,并连接到另一个数据库上。
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![jar](https://img-home.csdnimg.cn/images/20210720083455.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/ZIP.png)
共 69 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
python资深爱好者
- 粉丝: 578
- 资源: 195
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)