package addressbook.actions;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Locale;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.MissingResourceException;
import java.rmi.RemoteException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import addressbook.Constants;
import addressbook.model.UserBean;
/**
* This is the base class from which all Action classes that use
* Struts can be derived from. It takes into consideration some
* general architecture that would most likely be needed in a real
* application. For the purpose of this sample application, those methods that
* are not directly related to the Struts framework will be black-boxed
* and commented so that you can use this as a skeleton and fill in those
* methods as you see fit while you are doing development.
* <p>All action classes need to be derived from org.apache.struts.action.Action
* @see org.apache.struts.action.Action
*/
public abstract class AbstActionBase extends Action
{
private Log log =
LogFactory.getLog(this.getClass().getName());
/**
* Default constructor
*/
public AbstActionBase()
{
}
/*
* <strong>lookup</strong> is a blackbox method - lookup the EJB instance necessary.
* Typically action classes
* work with EJB session beans (or just JavaBeans) that contain the business logic for
* your application. In large scale projects, you want to keep a clean
* seperate of tier's. You would get the JNDI context, get an instance
* of the context, and then do a lookup on the given JNDI name for the
* EJB you are interested in to retrieve the home interface.
* This is provide as just a sample of what is needed.
* <p>Note: This method is not used in our application but included for
* information purposes only. The JNDI context is usually specific to how the
* application container requires its properties.
*@param String containing JNDI name to lookup.
*@return Object containing the home object looked up.
*@throws NamingException if the name lookup fails
*@throws MissingResourceException if can't get the resource bundle
*/
public Object lookup(String jndiName) throws NamingException, MissingResourceException
{
Context jndiContext = null;
//Set up the JNDI properties to get the initial context for calls to EJB objects
if (jndiContext == null) {
ResourceBundle resource = ResourceBundle.getBundle("addressbook.properties");
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, resource.getString(Context.INITIAL_CONTEXT_FACTORY));
properties.setProperty(Context.PROVIDER_URL, resource.getString(Context.PROVIDER_URL));
properties.setProperty(Context.SECURITY_PRINCIPAL, resource.getString(Context.SECURITY_PRINCIPAL));
properties.setProperty(Context.SECURITY_CREDENTIALS, resource.getString(Context.SECURITY_CREDENTIALS));
jndiContext = new InitialContext(properties);
}
// Note: For production, you probably want a robust try/catch block here to log any errors
// or important information. For this sample, any expceptions will just be thrown
// and we'll return the home object.
return (jndiContext.lookup(jndiName));
}
/**
* Check to make sure that we have a valid session.
* If the session is not valid, then forward to the Login page
* @param HttpServletRequest
* @return boolean valid session
*/
public boolean isSessionValid(HttpServletRequest request){
if (request == null) return (false);
HttpSession session = request.getSession();
if (session == null) return(false);
// Checked for a currently logged on user
UserBean user = (UserBean) session.getAttribute(Constants.USER_KEY);
return ((user == null) ? false : true);
}
public Hashtable getDatabase(){
return((Hashtable) servlet.getServletContext().getAttribute(Constants.DATABASE_KEY));
}
/**
* This is the main action called from the Struts framework.
* You can have this method call an abstract performAction method
* that is then implemented by each action class and do any specifics
* in this method that might be common to all actions, like logging.
* For this example, we are simply using the execute as the asbstract method.
* @param mapping The ActionMapping used to select this instance
* @param actionForm The optional ActionForm bean for this request (if any)
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
* @throws IOException if an input/output error occurs
* @throws ServletException if a servlet exception occurs
* @return ActionForwar - where control will be forwarded to after this request is processed
*/
public abstract ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception;
/*
{
// If you wanted to have another abstract method here, it is useful so that
// you can do things such as logging, as shown below.
ActionForward forward = null;
// Simple log to the servlet log for informational purposes
getServlet().log("AbstStrutsActionBase.execute() [Action Class: "+this.getClass().getName()+" ]");
getServlet().log("AbstStrutsActionBase.execute() [Form Class : "+(form == null ? "null" : form.getClass().getName())+" ]");
// Or you can use the logging mechanism
if (log.isDebugEnabled()) {
log.debug(AbstStrutsActionBase.execute() [Action Class: "+this.getClass().getName()+" ]");
log.debug("AbstStrutsActionBase.execute() [Form Class : "+(form == null ? "null" : form.getClass().getName())+" ]");
}
return(performAction(mapping, form, request, response));
}
*/
}
没有合适的资源?快使用搜索试试~ 我知道了~
java+struts开发的地址簿(AddressBook)源码
共223个文件
jsp:53个
class:49个
java:49个
5星 · 超过95%的资源 需积分: 10 21 下载量 194 浏览量
2010-01-26
21:00:06
上传
评论
收藏 1.8MB 7Z 举报
温馨提示
java+struts开发的地址簿(AddressBook)源码,内含三个版本!
资源推荐
资源详情
资源评论
收起资源包目录
java+struts开发的地址簿(AddressBook)源码 (223个子文件)
LogonAction.class 4KB
LogonAction.class 4KB
LogonAction.class 4KB
InsertAction.class 4KB
UserDatabasePlugIn.class 3KB
SearchAction.class 3KB
SearchAction.class 3KB
SearchAction.class 3KB
UserDatabaseServlet.class 3KB
UserDatabaseServlet.class 3KB
AddressBookBean.class 3KB
AddressBookBean.class 3KB
AddressBookBean.class 3KB
InsertAction.class 3KB
InsertAction.class 3KB
AbstActionBase.class 3KB
AbstActionBase.class 3KB
AbstActionBase.class 3KB
InsertForm.class 3KB
LogoffAction.class 2KB
LogoffAction.class 2KB
LogoffAction.class 2KB
DisplayTag.class 2KB
DisplayTag.class 2KB
DisplayTag.class 2KB
DisplayAllAction.class 2KB
DisplayAllAction.class 2KB
DisplayAllAction.class 2KB
InsertForm.class 2KB
InsertForm.class 2KB
ValidateSessionTag.class 2KB
ValidateSessionTag.class 2KB
ValidateSessionTag.class 2KB
SearchForm.class 2KB
SearchForm.class 2KB
SearchForm.class 2KB
LogonForm.class 2KB
LogonForm.class 2KB
LogonForm.class 2KB
PrepareInsertAction.class 1KB
DbUtil.class 1KB
DbUtil.class 1KB
DbUtil.class 1KB
UserBean.class 1KB
UserBean.class 1KB
UserBean.class 1KB
Constants.class 1011B
Constants.class 1011B
Constants.class 1011B
adrlogo.gif 2KB
adrlogo.gif 2KB
adrlogo.gif 2KB
struts-power.gif 2KB
struts-power.gif 2KB
struts-power.gif 2KB
commons-collections.jar 841KB
commons-collections.jar 841KB
commons-collections.jar 841KB
struts.jar 506KB
struts.jar 506KB
struts.jar 506KB
mysqldriver.jar 210KB
mysqldriver.jar 210KB
mysqldriver.jar 210KB
commons-digester.jar 178KB
commons-digester.jar 178KB
commons-digester.jar 178KB
commons-beanutils.jar 148KB
commons-beanutils.jar 148KB
commons-beanutils.jar 148KB
commons-validator.jar 79KB
commons-validator.jar 79KB
commons-validator.jar 79KB
jakarta-oro.jar 64KB
jakarta-oro.jar 64KB
jakarta-oro.jar 64KB
commons-logging.jar 39KB
commons-logging.jar 39KB
commons-logging.jar 39KB
commons-fileupload.jar 22KB
commons-fileupload.jar 22KB
commons-fileupload.jar 22KB
AbstActionBase.java 7KB
AbstActionBase.java 7KB
AbstActionBase.java 7KB
LogonAction.java 4KB
LogonAction.java 4KB
LogonAction.java 4KB
UserDatabasePlugIn.java 4KB
UserDatabaseServlet.java 4KB
UserDatabaseServlet.java 4KB
InsertAction.java 3KB
InsertAction.java 3KB
InsertAction.java 3KB
SearchAction.java 3KB
SearchAction.java 3KB
SearchAction.java 3KB
AddressBookBean.java 2KB
AddressBookBean.java 2KB
AddressBookBean.java 2KB
共 223 条
- 1
- 2
- 3
资源评论
- varanus2014-11-01不错,值得下载
动感星空
- 粉丝: 66
- 资源: 76
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于java的HTTP协议断点续传.zip
- Python实现ALO-LSTM蚁狮算法优化长短期记忆神经网络时间序列预测(完整源码和数据)
- 小智导航收录网 全新无网站域名限定版+简易的zblog导航网模版.rar
- 新版zblog模板仿糗事百科笑话网站模板 自适应主题.rar
- 响应式个人博客网站主题模板 zblog模板.rar
- 梯度下降算法是一种优化算法,通常用于最小化某个损失函数 它被广泛应用于机器学习和深度学习领域,用于更新模型参数以使损失函数最小化
- 1080K影视网站苹果CMSV10模版.rar
- GWO-HKELM灰狼算法优化混合核极限学习机多变量回归预测(Matlab完整源码和数据)
- 一个简单的 Python 类设计案例,实现一个简单的学生管理系统
- 健康监测的微信小程序页面源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功