Re: Servlet and openamf
Todd Hivnor <[email protected]> Tue, 03 Apr 2007 08:47:31 -0700
| Newsgroups | gmane.comp.java.openamf.user |
|---|---|
| Message-ID | <[email protected]> |
When people get started with OpenAMF they often want to create a
servlet. But the required servlet is already provided by OpenAMF. It is
org.openamf.AdvancedGateway. The AdvancedGateway has a configuration
file (typically openamf-config.xml) which governs what service classes
and methods are available. So for basic usage, you generally do not want
to create a servlet. You want to use the provided AdvancedGateway
servlet, and provide your own "services" as basic Java classes.
If you really need a reference to the HttpServletRequest or
HttpServletResponse, you can access this with
org.openamf.RequestContext. Raw access to the HttpServletResponse is
somewhat dangerous. You should NOT do the following, for example:
RequestContext.getHttpServletResponse().getOutputStream()
Parag Dharmadhikari wrote:
>
> Hi All,
>
> After battle with code I could figure out that by using
> AdvancedGateway and by extending TestServlet from
> org.openamf.AdvancedGateway atleast I could invoke method from
> servlet. This method is normal java method. But still could not
> understand how I could get hold of request & response object in
> servlet class. Because neither service() nor doPost/doGet methods are
> getting invoked.
>
> My Servlet code is
>
> *package* com.flashdb.services.servlets;
>
> *import* javax.servlet.ServletException;
>
> *import* javax.servlet.http.HttpServletRequest;
>
> *import* javax.servlet.http.HttpServletResponse;
>
> *import* com.flashdb.services.remoteHelloWorld;
>
> *import* org.openamf.AdvancedGateway;
>
> *import* org.openamf.examples.Authentication;
>
> *public* *class* TestServlet *extends* AdvancedGateway {
>
> *public* *void* init() *throws* ServletException {
>
> System./out/.println("inside init");
>
> }
>
> /**public* *void* service (HttpServletRequest request,
> HttpServletResponse response){
>
> System./out/.println("inside service");
>
> }*/
>
> *public* *void* doGet (HttpServletRequest request, HttpServletResponse
> response){
>
> System./out/.println("inside doGet");
>
> }
>
> *public* *void* doPost (HttpServletRequest request,
> HttpServletResponse response){
>
> System./out/.println("inside doPost");
>
> }
>
> *public* String echo(String msg,Authentication authentication){
>
> System./out/.println("inside echo");
>
> *return* msg;
>
> }
>
> }
>
> echo() method is getting invoked but I am interested in getting hold
> of HttpServletRequest & HttpServletResponse.
>
> And openamf-config.xml is
>
> <service>
>
> <name>TestServlet</name>
>
> <service-location>com.flashdb.services.servlets.TestServlet</service-location>
>
> <invoker-ref>Java</invoker-ref>
>
> <method>
>
> <!-- Operation's are matched by the name and parameters -->
>
> <name>echo</name>
>
> <state-bean-ref>
>
> <name>Authentication</name>
>
> </state-bean-ref>
>
> <parameter>
>
> <!--
>
> type can be the the name of the class,
>
> a * for any types,
>
> or a ? any 1 type
>
> -->
>
> <type>*</type>
>
> </parameter>
>
> </method>
>
> </service>
>
> Can anybody help me?
>
> Regards
>
> Parag
>
> ------------------------------------------------------------------------
>
> *From:* [email protected]
> [mailto:[email protected]] *On Behalf Of
> *Parag Dharmadhikari
> *Sent:* Tuesday, April 03, 2007 12:45 PM
> *To:* [email protected]
> *Subject:* Re: [Openamf-user] Servlet and openamf
> *Importance:* High
>
> Sorry for typo error… point 1 should then become
> myservice.TestServlet(“hi”);
>
> ------------------------------------------------------------------------
>
> *From:* [email protected]
> [mailto:[email protected]] *On Behalf Of
> *Parag Dharmadhikari
> *Sent:* Tuesday, April 03, 2007 12:28 PM
> *To:* [email protected]
> *Subject:* [Openamf-user] Servlet and openamf
>
> Hi All,
>
> After writing the simple java class with openamf, I am trying to
> invoke servlet with openamf. But I have following doubts:
>
> 1. In flash MX we can call service method of the servlet. So can
> same be done in openamf.
>
> So my flash code would become
>
> myService = new
> Service("http://172.20.77.162:8080/helloWorld/gateway",myLogger,"com.flashdb.services.servlets.TestServlet",null,null);
>
> And then invoke myservice.service();
>
> 2. As per Flash MX document service() method is executed from
> servlet so in case of openamf what is the course of action? Can
> doGet() or doPost() be invoked in same way?
> 3. Also in Flash MX, service () method receives FLASH.PARAMS
> argument which is java.util.list so in case of openamf can I use
> same parameter or there is different parameter / tech. to be used?
>
> Kindly guide me for above queries.
>
> Regards
>
> Parag
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> ------------------------------------------------------------------------
>
> _______________________________________________
> Openamf-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/openamf-user
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV