📄 csdn 文档中心:java开发之flash remoting调用servlet.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0081)http://kb.csdn.net/java/Articles/200503/b969728b-1f72-4b91-8990-5d167bd4bde0.html -->
<HTML><HEAD><TITLE
id=PageTitle>CSDN 文档中心:java开发之Flash remoting调用servlet</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8"><LINK
href="CSDN 文档中心:java开发之Flash&nbsp;remoting调用servlet.files/JavaCh1.css"
type=text/css rel=stylesheet><LINK
href="CSDN 文档中心:java开发之Flash&nbsp;remoting调用servlet.files/CSDN_Common_HF.css"
type=text/css rel=stylesheet>
<STYLE type=text/css>.newsTitle {
OVERFLOW: hidden; WIDTH: 150px; TEXT-OVERFLOW: ellipsis
}
</STYLE>
<SCRIPT language=javascript type=text/javascript>
var maxWidth = 600;
function AutoResizeImages()
{
var imgs = document.getElementsByTagName("img");
for(var i = 0; i < imgs.length; i++)
{
if(imgs[i].className != "FixedWidth")
{
if(imgs[i].width > maxWidth) imgs[i].width = maxWidth;
}
}
}
</SCRIPT>
<META content="MSHTML 6.00.2900.2180" name=GENERATOR></HEAD>
<BODY onload=AutoResizeImages();><!-- saved from url=(0022)http://internet.e-mail --><!-- 公共页头 -->
<DIV style="TEXT-ALIGN: center">
<DIV id=CHBig>
<DIV id=CHBigCSDNLogo><IMG height=60 alt=中国软件网
src="CSDN 文档中心:java开发之Flash&nbsp;remoting调用servlet.files/logo_csdn.gif"
width=150 border=0></DIV>
<DIV id=CHBigHeaderWrapper>
<DIV id=CHBigFuncBar>
<UL>
<LI><A href="http://www.csdn.net/member/UserLogin.aspx">【登录】</A>
<LI><A href="http://www.csdn.net/member/zc.asp">【免费注册】</A></LI></UL></DIV>
<DIV id=CHBigNavBar1>
<SCRIPT
src="CSDN 文档中心:java开发之Flash&nbsp;remoting调用servlet.files/MainNavBar.js"
type=text/javascript></SCRIPT>
</DIV>
<DIV id=CHBigNavBar2>
<SCRIPT
src="CSDN 文档中心:java开发之Flash&nbsp;remoting调用servlet.files/QuickNavBar.js"
type=text/javascript></SCRIPT>
</DIV></DIV>
<DIV style="CLEAR: both"></DIV></DIV></DIV><!-- /公共页头 -->
<DIV id=OutBox>
<FORM id=CSDNFrontEndForm name=CSDNFrontEndForm
action=display.aspx?GUID=b969728b-1f72-4b91-8990-5d167bd4bde0 method=post><INPUT
type=hidden value=dDwyMDY0NTMxNTgyOzs+gROpI4qhIrPt0z+gKakFsmlJciY=
name=__VIEWSTATE>
<DIV id=listMainArea>
<DIV id=SimpleNav>
<DIV id=listSimpleNav>您的位置:<A href="http://www.csdn.net/" target=_blank>CSDN
首页</A> -> <A href="http://kb.csdn.net/" target=_blank>知识库</A> ->
文章摘要</DIV></DIV>
<DL class=ReadArticle>
<DT><SPAN id=LblTitle>java开发之Flash remoting调用servlet</SPAN>
<DD class=ArticleInfo>作者: <A id=HyperAuthor
href="http://kb.csdn.net/ArticleAuthor.aspx?author="></A>∣来源:<A id=HyFromWhere
href="http://www.javaresearch.org/article/" target=_blank>JavaResearch</A>∣<A
id=HyHistoryUrl
title=http://www.javaresearch.org/article/showarticle.jsp?column=2&thread=24467
href="http://www.javaresearch.org/article/showarticle.jsp?column=2&thread=24467"
target=_blank>原文地址</A>∣<SPAN id=LblUpdateDate>2005-3-31</SPAN>
<DD class=ArticleContent>
<DIV class=HideDiv style="OVERFLOW: hidden; WIDTH: 100%"><SPAN
id=LblContent>java开发之Flash remoting调用servlet <BR><BR>作者:水分子 时间:2004-11-8 12:52:37 类型:原创 来源:RIACN<BR>统计信息: 总计:329 今日:1 评论数:4<BR> <BR>【字体:大 中 小】【打印本稿】【进入论坛】 <BR>服务器:jrun4 <BR>组件:flash remoting components as2.0 <BR>软件:flash mx 2004 pro <BR>在安装好后,打开jrun4的管理页面,进入页面之后你会看到jrun已经创建好了3个服务器,分别是admin,default和samples,我们使用的服务器为default,对与flash remoting的相关用法可参照lwanchen的flashremoting实践(三)-hello world for java:<A
href="http://www.riacn.com/web/showArticle.asp?id=111">http://www.riacn.com/web/showArticle.asp?id=111</A> <BR><BR>1.在C:\jrun4\servers\default\default-ear\default-war\WEB-INF的web.xml中加入以下的标记: <BR><BR><servlet> <servlet-name>MyServlet</servlet-name> <display-name>MyServlet</display-name> <description>This is a servlet of H2O</description> <servlet-class>MyServlet</servlet-class> </servlet> 2.将编译好的MyServlet.class这个servlet放在classes文?邢?<BR><BR>MyServlet.java为 <BR>
<DIV class=codeStyle>
<OL>
<LI>
<LI><B><FONT color=#0000ff>import</FONT></B> javax.servlet.*;
<LI><B><FONT color=#0000ff>import</FONT></B> java.io.<B><A
href="http://kb.csdn.net/source/jdk142/java/io/IOException.java.html"
target=_blank><FONT class=classLink><U>IOException</U></FONT></A></B>;
<LI><B><FONT color=#0000ff>import</FONT></B> java.util.<B><A
href="http://kb.csdn.net/source/jdk142/java/util/List.java.html"
target=_blank><FONT class=classLink><U>List</U></FONT></A></B>;
<LI>
<LI><B><FONT color=#0000ff>public</FONT></B> <B><FONT
color=#0000ff>class</FONT></B> MyServlet <B><FONT
color=#0000ff>implements</FONT></B> <A
href="http://kb.csdn.net/source/j2ee1.3.1/javax/servlet/Servlet.java.html"
target=_blank><FONT class=classLink><U>Servlet</U></FONT></A> {
<LI> <B><FONT color=#0000ff>private</FONT></B> <B><A
href="http://kb.csdn.net/source/jdk142/java/lang/String.java.html"
target=_blank><FONT
class=classLink><U>String</U></FONT></A></B> message = <B><FONT
color=#0000ff>null</FONT></B>;
<LI>
<LI> <B><FONT color=#0000ff>public</FONT></B> <B><FONT
color=#0000ff>void</FONT></B> init(<A
href="http://kb.csdn.net/source/j2ee1.3.1/javax/servlet/ServletConfig.java.html"
target=_blank><FONT
class=classLink><U>ServletConfig</U></FONT></A> config) <B><FONT
color=#0000ff>throws</FONT></B> <A
href="http://kb.csdn.net/source/j2ee1.3.1/javax/servlet/ServletException.java.html"
target=_blank><FONT
class=classLink><U>ServletException</U></FONT></A> {
<LI> message = <FONT
color=#ff33ff>"Hello from MyServlet"</FONT>;
<LI> }
<LI>
<LI> <B><FONT color=#0000ff>public</FONT></B> <B><FONT
color=#0000ff>void</FONT></B> service(<A
href="http://kb.csdn.net/source/j2ee1.3.1/javax/servlet/ServletRequest.java.html"
target=_blank><FONT
class=classLink><U>ServletRequest</U></FONT></A> request, <A
href="http://kb.csdn.net/source/j2ee1.3.1/javax/servlet/ServletResponse.java.html"
target=_blank><FONT
class=classLink><U>ServletResponse</U></FONT></A> response)
<LI> <B><FONT
color=#0000ff>throws</FONT></B> <A
href="http://kb.csdn.net/source/j2ee1.3.1/javax/servlet/ServletException.java.html"
target=_blank><FONT
class=classLink><U>ServletException</U></FONT></A>, <B><A
href="http://kb.csdn.net/source/jdk142/java/io/IOException.java.html"
target=_blank><FONT class=classLink><U>IOException</U></FONT></A></B> {
<LI> request.setAttribute(<FONT
color=#ff33ff>"FLASH.RESULT"</FONT>, message);
<LI> }
<LI>
<LI> <B><FONT color=#0000ff>public</FONT></B> <B><A
href="http://kb.csdn.net/source/jdk142/java/lang/String.java.html"
target=_blank><FONT
class=classLink><U>String</U></FONT></A></B> getServletInfo() {
<LI> <B><FONT
color=#0000ff>return</FONT></B> <FONT
color=#ff33ff>"A test servlet."</FONT>;
<LI> }
<LI>
<LI> <B><FONT color=#0000ff>public</FONT></B> <A
href="http://kb.csdn.net/source/j2ee1.3.1/javax/servlet/ServletConfig.java.html"
target=_blank><FONT
class=classLink><U>ServletConfig</U></FONT></A> getServletConfig() {
<LI> <B><FONT
color=#0000ff>return</FONT></B> <B><FONT color=#0000ff>null</FONT></B>;
<LI> }
<LI>
<LI> <B><FONT color=#0000ff>public</FONT></B> <B><FONT
color=#0000ff>void</FONT></B> destroy() {
<LI> message = <B><FONT
color=#0000ff>null</FONT></B>;
<LI> }
<LI>}
</LI></OL></DIV> <BR>3.在flash mx 2004 pro中的调用方法为: <BR>import mx.remoting.NetServices; <BR>import mx.remoting.Connection; <BR>NetServices.setDefaultGatewayUrl("http://localhost:8100/flashservices/gateway";); <BR>gatewayConnnection = NetServices.createGatewayConnection(); <BR>flashtestService = gatewayConnnection.getService("",this); flashtestService.MyServlet(); <BR>function MyServlet_Result(result){ <BR> users= result; trace(users); <BR>}<BR> ok! 就是这么简单,但可花费了我不少的心血呀,希望大家珍惜,也祝大家能一次搞定!<BR><BR>水分子(H2O) 2004.11.8 1509@163.COM <BR> <BR><BR><BR></SPAN></DIV></DD></DL>
<HR noShade SIZE=1>
<DL>
<DT>作者的其他文章
<DD>
<UL>
<LI><A id=RepAuthor__ctl0_HyperArticle
href="http://kb.csdn.net/java/Articles/200603/025bb167-e37b-4f14-98d2-0cb077be3f31.html">.NET
点滴</A>
<LI><A id=RepAuthor__ctl1_HyperArticle
href="http://kb.csdn.net/java/Articles/200603/4a316f5e-f61f-4394-aa6f-64609ae5fa9c.html">用好Google的"手气不错"——我是这样找软件的</A>
<LI><A id=RepAuthor__ctl2_HyperArticle
href="http://kb.csdn.net/java/Articles/200603/b3a2d154-0089-40e2-ab27-f068d308aabb.html">wxPython创建系统托盘</A>
<LI><A id=RepAuthor__ctl3_HyperArticle
href="http://kb.csdn.net/java/Articles/200603/9c839f31-b1c7-446c-82c0-d3208eaf44e4.html">The
Suggested Upper Merged Ontology(SUMO)——推荐高层合并本体1</A>
<LI><A id=RepAuthor__ctl4_HyperArticle
href="http://kb.csdn.net/java/Articles/200603/6e086e3e-9c8c-4356-8d21-4c6ecd5355ff.html">老师的一封回信</A>
<LI><A id=RepAuthor__ctl5_HyperArticle
href="http://kb.csdn.net/java/Articles/200603/10ce2207-2737-456f-a252-6e6356b9f1ae.html">用javascript实现对链接或按钮执行的确认</A>
<LI><A id=RepAuthor__ctl6_HyperArticle
href="http://kb.csdn.net/java/Articles/200603/92a12675-5ae7-4d2c-b733-296eec22cbb2.html">ASP常用的分页方法</A>
<LI><A id=RepAuthor__ctl7_HyperArticle
href="http://kb.csdn.net/java/Articles/200603/29f05311-f3d2-472f-9c14-e60fae4c2ff7.html">对IBM的不可忍</A>
<LI><A id=RepAuthor__ctl8_HyperArticle
href="http://kb.csdn.net/java/Articles/200603/786d1fbf-6158-4dc7-8a27-68a303b21978.html">Switching
Between HTTP and HTTPS Automatically</A>
<LI><A id=RepAuthor__ctl9_HyperArticle
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -