Calling A Servlet Or Jsp - MACROMEDIA FLASH REMOTING MX-USING FLASH REMOTING FOR FLASH MX 2004 ACTIONSCRIPT 2.0 Use Manual

Using flash remoting for flash mx 2004 actionscript 2.0
Table of Contents

Advertisement

Calling a servlet or JSP

To call a servlet or a JSP defined as a servlet from ActionScript, use the servlet name specified in
the web application's web.xml deployment descriptor file as an ActionScript function name. For
example, the servlet name is MyServlet in the following example:
function go_Clicked()
{
var pc:mx.remoting.PendingCall = servletService.MyServlet();
pc.responder = new RelayResponder( this, "MyServlet_Result",
"onCategoryFault" );
// etc.
}
The web.xml file contains the following servlet definition:
<servlet>
<servlet-name>MyServlet</servlet-name>
<display-name>MyServlet</display-name>
<description>Simple text servlet</description>
<servlet-class>MyServlet</servlet-class>
</servlet>
Note: On Servlet 2.3-compliant application servers, you can define a JSP as a servlet by specifying a
JSP filename in a JSP-file element, rather than a servlet class in a servlet-class element.
Request arguments sent from Flash as parameters of the
from the Request scope as the parameter
the request parameter
import javax.servlet.*;
import java.io.IOException;
import java.util.List;
public class MyServlet implements Servlet
{
private String message = null;
public void init(ServletConfig config) throws ServletException
{
message = "Hello from MyServlet";
}
public void service(ServletRequest request, ServletResponse response)
throws ServletException, IOException
{
// The args could be used here too...
/*
Object o = request.getAttribute("FLASH.PARAMS");
if (o instanceof List)
{
List args = (List)o;
}
Object arg0 = args.get(0);
Object arg1 = args.get(1);
*/
request.setAttribute("FLASH.RESULT", message);
"FLASH.PARAMS"
, as shown in the following servlet:
"FLASH.RESULT"
function are available
ServletName()
. You can return results to Flash using
Calling servlets and JSPs from Flash
133

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH REMOTING MX-USING FLASH REMOTING FOR FLASH MX 2004 ACTIONSCRIPT 2.0 and is the answer not in the manual?

This manual is also suitable for:

Flash remoting mx

Table of Contents