📄 737_4.asp.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<meta name="Author" content="www.blueidea.com">
<link href="737_4.asp_files/style.css" rel="stylesheet" type="text/css">
<link rel="apple-touch-icon" href="http://www.blueidea.com/img/common/bi_logo.png">
<script language="JavaScript" src="737_4.asp_files/ajs.js"></script><script type="text/javascript" src="737_4.asp_files/flashobject.js"></script>
<title>实战留言簿(EJB,Struts应用篇) - 网络编程 - 蓝色理想</title>
<meta name="keywords" content="J2EE,留言簿,EJB,STRUCTS">
<meta name="publishDate" content="2003-9-14 15:48:01">
<meta name="updateDate" content="2004-2-2 14:21:48">
<meta name="generatDate" content="2007-5-10 17:39:46">
</head><body>
<table class="border" border="0" cellpadding="0" cellspacing="6" width="778">
<tbody><tr>
<td class="logoBackground" align="center" width="101"><a href="http://www.blueidea.com/"><img src="737_4.asp_files/logo.gif" border="0" width="90" height="27"></a>
</td>
<td valign="top" width="659">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="31">
<tbody><tr valign="top">
<td><table class="navDark" border="0" cellpadding="0" cellspacing="6" width="100%"><tbody><tr><td align="center"><a href="http://www.blueidea.com/news/index.asp" class="navLink">业界动态</a></td></tr></tbody></table></td>
<td width="6"><img src="737_4.asp_files/spacer.gif" width="6" height="6"></td>
<td class="navLight"><table border="0" cellpadding="0" cellspacing="6" width="100%"><tbody><tr><td align="center"><b><a href="http://www.blueidea.com/tech/index.asp" class="navLink">技术文档</a></b></td></tr></tbody></table></td>
<td width="6"><img src="737_4.asp_files/spacer.gif" width="6" height="6"></td>
<td><table class="navDark" border="0" cellpadding="0" cellspacing="6" width="100%"><tbody><tr><td align="center"><a href="http://www.blueidea.com/design/index.asp" class="navLink">艺术设计</a></td></tr></tbody></table></td>
<td width="6"><img src="737_4.asp_files/spacer.gif" width="6" height="6"></td>
<td><table class="navDark" border="0" cellpadding="0" cellspacing="6" width="100%"><tbody><tr><td align="center"><a href="http://www.blueidea.com/photo/index.asp" class="navLink">摄影摄像</a></td></tr></tbody></table></td>
<td width="6"><img src="737_4.asp_files/spacer.gif" width="6" height="6"></td>
<td><table class="navDark" border="0" cellpadding="0" cellspacing="6" width="100%"><tbody><tr><td align="center"><a href="http://www.blueidea.com/computer/index.asp" class="navLink">计算机技术</a></td></tr></tbody></table></td>
<td width="6"><img src="737_4.asp_files/spacer.gif" width="6" height="6"></td>
<td><table class="navDark" border="0" cellpadding="0" cellspacing="6" width="100%"><tbody><tr><td align="center"><a href="http://www.blueidea.com/download/index.asp" class="navLink">资源下载</a></td></tr></tbody></table></td>
<td width="6"><img src="737_4.asp_files/spacer.gif" width="6" height="6"></td>
<td><table class="navDark" border="0" cellpadding="0" cellspacing="6" width="100%"><tbody><tr><td align="center"><a href="http://www.blueidea.com/column/index.asp" class="navLink">个人专栏</a></td></tr></tbody></table></td>
<td width="6"><img src="737_4.asp_files/spacer.gif" width="6" height="6"></td>
<td><table class="navDark" border="0" cellpadding="0" cellspacing="6" width="100%"><tbody><tr><td align="center"><a href="http://www.blueidea.com/cg/index.asp" class="navLink">CG绘画</a></td></tr></tbody></table></td>
<td width="6"><img src="737_4.asp_files/spacer.gif" width="6" height="6"></td>
<td><table class="navDark" border="0" cellpadding="0" cellspacing="6" width="100%"><tbody><tr><td align="center"><a href="http://www.blueidea.com/special/index.asp" class="navLink">专题</a></td></tr></tbody></table></td>
<td width="6"><img src="737_4.asp_files/spacer.gif" width="6" height="6"></td>
<td>
<table class="navDark" border="0" cellpadding="0" cellspacing="6" width="100%">
<tbody><tr>
<td align="center"><a href="http://bbs.blueidea.com/" class="navLink">经典论坛</a></td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
<table class="navLight" border="0" cellpadding="0" cellspacing="6" width="100%">
<tbody><tr>
<td><font color="#ffffff">
<a href="http://www.blueidea.com/tech/web/index.asp" class="navLink">网页制作</a> | <a href="http://www.blueidea.com/tech/graph/index.asp" class="navLink">图形图像</a> | <a href="http://www.blueidea.com/tech/multimedia/index.asp" class="navLink">多媒体制作</a> | ·<a href="http://www.blueidea.com/tech/program/index.asp" class="navLink"><b>网络编程</b></a> | <a href="http://www.blueidea.com/tech/site/index.asp" class="navLink">网站建设</a>
</font></td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
<table class="border" border="0" cellpadding="0" cellspacing="0" width="778">
<tbody><tr>
<td align="center" height="10">
<table class="pageSeparator" border="0" cellpadding="0" cellspacing="6" width="766">
<tbody><tr>
<td><span class="location">您的位置: <a href="http://www.blueidea.com/index.asp">首页</a> > <a href="http://www.blueidea.com/tech/index.asp">技术文档</a> > <a href="http://www.blueidea.com/tech/program/index.asp">网络编程</a> > 实战留言簿(EJB,Struts应用篇)</span></td>
</tr>
</tbody></table></td>
</tr>
</tbody></table>
<table class="border" border="0" cellpadding="0" cellspacing="6" width="778">
<tbody><tr>
<td class="pageLight" align="center" valign="top" width="540"><script language="JavaScript">showbanner(2,2);</script><a href="http://bbs.blueidea.com/forum-19-1.html" target="_blank"><img src="737_4.asp_files/job.gif" alt="网站开发招聘" border="" width="533" height="104"></a><table class="border" border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<td align="center"><img src="737_4.asp_files/spacer.gif" width="6" height="6"></td>
</tr>
</tbody></table>
<table class="pageIcon" border="0" cellpadding="1" cellspacing="0" width="100%">
<tbody><tr>
<td width="227"><img src="737_4.asp_files/prev.gif" align="absmiddle" width="15" height="15"> <a href="http://www.blueidea.com/tech/program/2003/747.asp">数据库正规化和设计技巧</a></td>
<td align="center" width="80"><img src="737_4.asp_files/list.gif" align="absmiddle" width="15" height="15"> <a href="http://www.blueidea.com/tech/program/"><font color="#999999">回到列表</font></a></td>
<td align="right" width="227"><img src="737_4.asp_files/next.gif" align="absmiddle" width="15" height="15"> <a href="http://www.blueidea.com/tech/program/2003/734.asp">ASP 中 Split 函数的实例</a></td>
</tr>
</tbody></table>
</td>
<td class="listcontent" align="center" valign="top" width="220">
<table cellpadding="3"><tbody><tr><td><a target="_blank" href="http://99ut.blueidea.com/"><img src="737_4.asp_files/99ut.gif" alt="" border="0"></a></td></tr></tbody></table>
<script language="JavaScript">showbanner(4,4);</script><a href="http://info.cgfinal.com/html/cms/2007/12/01/1196438494.shtml" target="_blank"><img src="737_4.asp_files/cgart.gif" alt="CG艺术第10期再战江湖" border="" width="206" height="33"></a>
</td>
</tr>
</tbody></table>
<!--<table width="778" border="0" cellpadding="0" cellspacing="0" class="border">
<tr>
<td align="center"><table width="766" border="0" cellpadding="0" cellspacing="0" class="pageSeparator">
<tr>
<td align="center"><img src="/img/spacer.gif" width="12" height="12"></td>
</tr>
</table></td>
</tr>
</table>-->
<table class="border" border="0" cellpadding="0" cellspacing="0" width="778">
<tbody><tr>
<td align="center"><table border="0" cellpadding="0" cellspacing="0" width="766">
<tbody><tr>
<td align="center"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="750" height="80"><param name="movie" value="http://gg.blueidea.com/2008/intel/2/a.swf"><param name="wmode" value="opaque"><param name="quality" value="autohigh"><embed src="737_4.asp_files/a.swf" quality="autohigh" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="opaque" width="750" height="80"></object></td>
</tr>
</tbody></table></td>
</tr>
</tbody></table>
<table class="border" border="0" cellpadding="0" cellspacing="6" width="778">
<tbody><tr>
<td class="pagelighter" valign="top" width="540">
<table class="listtitle" border="0" cellpadding="1" cellspacing="0" width="100%">
<tbody><tr>
<td>
<table class="pageSubject" border="0" cellpadding="0" cellspacing="6" width="100%">
<tbody><tr>
<td class="content"><strong> 实战留言簿(EJB,Struts应用篇)
</strong></td>
</tr>
</tbody></table>
<table class="docParameter" border="0" cellpadding="0" cellspacing="6" width="100%">
<tbody><tr>
<td><p>作者:<a href="http://www.blueidea.com/common/contact.asp?type=%D7%F7%D5%DF&username=maxuan" target="_blank">maxuan</a> 时间: 2003-09-14 文档类型:原创 来自:<a href="http://www.blueidea.com/">蓝色理想</a>
<br></p>
<p class="list"><img src="737_4.asp_files/arrow_orange.gif" width="4" height="13"> 第 1 页 <a href="http://www.blueidea.com/tech/program/2003/737.asp">实战留言簿(EJB,Struts应用篇)[1]</a><br><img src="737_4.asp_files/arrow_orange.gif" width="4" height="13"> 第 2 页 <a href="http://www.blueidea.com/tech/program/2003/737_2.asp">实战留言簿(EJB,Struts应用篇)[2]</a><br><img src="737_4.asp_files/arrow_orange.gif" width="4" height="13"> 第 3 页 <a href="http://www.blueidea.com/tech/program/2003/737_3.asp">实战留言簿(EJB,Struts应用篇)[3]</a><br><img src="737_4.asp_files/arrow_red.gif" width="4" height="13"> 第 4 页 实战留言簿(EJB,Struts应用篇)[4]<br><img src="737_4.asp_files/arrow_orange.gif" width="4" height="13"> 第 5 页 <a href="http://www.blueidea.com/tech/program/2003/737_5.asp">实战留言簿(EJB,Struts应用篇)[5]</a><br><img src="737_4.asp_files/arrow_orange.gif" width="4" height="13"> 第 6 页 <a href="http://www.blueidea.com/tech/program/2003/737_6.asp">实战留言簿(EJB,Struts应用篇)[6]</a><br></p>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
<table class="border" border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<td><img src="737_4.asp_files/spacer.gif" width="6" height="6"></td>
</tr>
</tbody></table>
<table class="pageLighter" border="0" cellpadding="0" cellspacing="11" width="100%">
<tbody><tr>
<td class="content">
<p> 有了Struts资源的调用,我们继续来完成JAVABEAN部分的编写!首先,我们编写PAction.java文件来完成连接等初始化工作。<br><strong>PAction.java源代码:</strong><br><textarea class="codeTextarea">package guestbook.maxuan.action;
import javax.naming.*;
import java.util.Properties;
import java.util.*;
import javax.rmi.PortableRemoteObject;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Locale;
import java.util.Vector;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.util.MessageResources;
import guestbook.maxuan.ejb.control.*;
public class PAction extends Action{
//public ActionErrors errors = new ActionErrors();
public BookControl control = null;
public Context getInitialContext() {
String url = "t3://127.0.0.1:";
String user = null;
String password = null;
Properties properties = null;
ActionServlet actionServlet = this.getServlet();
String port = actionServlet.getServletConfig().getInitParameter("port");
url = url + port;
try {
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, url);
if (user != null) {
properties.put(Context.SECURITY_PRINCIPAL, user);
properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
}
return new InitialContext(properties);
}
catch(Exception e) {
e.printStackTrace();
}
return null;
}
public BookControl getInitControl( ){
BookControl control = null;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -