Re: Redirecting OpenAMF requests passing throughafilter.

"David Lush" <[email protected]> Thu, 24 Aug 2006 15:13:02 +0100
Newsgroups gmane.comp.java.openamf.user
Message-ID <C4E45EF8549D704DB8B37E1ED5701C9516ADBE@officeserver.sbs.Powertec.co.uk>
Hi again all,

             Please ignore my ramblings. I've now realised that I've
been trying to set a redirect on data that is being returned to the
flash movie as AMF rather than the containing browser. I think I've also
been committing the response once then the gateway Servlet has been
committing it a second time.

Anyways, I've just worked around it by bundling up a timeout error in
the value objects I'm returning to my flash then allowing the flash to
re-direct to an error page. Hopefully this will be of a little help to
someone in the future :-)

Cheers

Dave

 

________________________________

From: [email protected]
[mailto:[email protected]] On Behalf Of David
Lush
Sent: 23 August 2006 16:07
To: [email protected]
Subject: Re: [Openamf-user] Redirecting OpenAMF requests passing
throughafilter.

 

Ahhh... jus noticed another detail that probably makes a difference to
this. Each instance of the gateway is accepting multiple concurrent
requests to different methods. E.g

 

[#|2006-08-23T16:02:51.677+0100|INFO|sun-appserver-pe8.1_02|org.openamf.
RESPONSE|_ThreadID=22;|RESPONSE:

[AMFBody: {serviceName=null, serviceMethodName=null, response=null,
type=UNKNOWN, value=ASObject[type=interfaceobjects.roster.CalendarVO]}]

[AMFBody: {serviceName=null, serviceMethodName=null, response=null,
type=UNKNOWN,
value=ASObject[type=interfaceobjects.personaldata.PersonalInfoVO]}]

[AMFBody: {serviceName=null, serviceMethodName=null, response=null,
type=UNKNOWN,
value=ASObject[type=interfaceobjects.booking.RequestTypesVO]}]

[AMFBody: {serviceName=null, serviceMethodName=null, response=null,
type=UNKNOWN, value=[Ljava.lang.String;@ff6a9a}]

[AMFBody: {serviceName=null, serviceMethodName=null, response=null,
type=UNKNOWN, value=16-03-08}]

[AMFBody: {serviceName=null, serviceMethodName=null, response=null,
type=UNKNOWN,
value=ASObject[type=interfaceobjects.personaldata.NotAvailVO]}]

[AMFBody: {serviceName=null, serviceMethodName=null, response=null,
type=UNKNOWN,
value=ASObject[type=interfaceobjects.messagesystem.NewMessageHeadersVO]}
]

|#]

[#|2006-08-23T16:02:51.677+0100|INFO|sun-appserver-pe8.1_02|org.openamf.
io.AMFSerializer|_ThreadID=22;|Serializing Message, for more info turn
on debug level|#]

[#|2006-08-23T16:02:52.756+0100|INFO|sun-appserver-pe8.1_02|org.openamf.
io.AMFDeserializer|_ThreadID=23;|Deserializing Message, for more info
turn on debug level|#]

[#|2006-08-23T16:02:52.756+0100|INFO|sun-appserver-pe8.1_02|org.openamf.
REQUEST|_ThreadID=23;|REQUEST:

[AMFBody: {serviceName=SelfServiceOldBD, serviceMethodName=getFirstDate,
response=/10, type=ARRAY, value=[]}]

[AMFBody: {serviceName=SelfServiceOldBD, serviceMethodName=getLastDate,
response=/11, type=ARRAY, value=[]}]

[AMFBody: {serviceName=SelfServiceOldBD, serviceMethodName=getCellInfo,
response=/12, type=ARRAY, value=[23-08-06]}]

[AMFBody: {serviceName=SelfServiceOldBD,
serviceMethodName=getRosterInfo, response=/13, type=ARRAY,
value=[23-08-06]}]

 

 

These requests were all fired off from one movie at near enough the same
time. They are then being handled by only two threads on the server.
Does the Gateway Servlet commit one combined response? Or will it
service each Remoting call separately?

Just thinking out loud more than anything :-)

Cheers

Dave

 

________________________________

From: [email protected]
[mailto:[email protected]] On Behalf Of David
Lush
Sent: 23 August 2006 15:51
To: [email protected]
Subject: [Openamf-user] Redirecting OpenAMF requests passing through
afilter.

 

Afternoon all,

            I'm currently working on a project with a number of flash
movies connecting to one OpenAMF service (AdvancedGateway). I've
recently done a bit of work to introduce a JAAS authentication system
and am now working on a Filter to restrict access to URL's the user is
not authenticated for. This is working ok and allows me to block access
to swf's, html's, the gateway service etc...

My problem comes when I want to re-direct someone to an error page based
on a remoting request (either because the request is not allowed or the
user's session has timed out etc...).

 

I have my error page defined in the web.xml as follows 

 

<error-page>

    <error-code>403</error-code>

    <location>/errors/403.jsp</location>

</error-page>

 

And re-direct to the error page in the filter as follows 

 

    myResponse.sendError(myResponse.SC_FORBIDDEN);

    chain.doFilter(myRequest, myResponse);

 

The main problem I'm having is that if I try to re-direct a remoting
request it puts the Servlet into an IllegalState as follows

 

[#|2006-08-23T15:44:46.701+0100|SEVERE|sun-appserver-pe8.1_02|javax.ente
rprise.system.container.web|_ThreadID=36;|org.apache.catalina.core.Stand
ardHostValve@a755f5: Exception Processing ErrorPage[errorCode=403,
location=/errors/403.jsp]

java.lang.IllegalStateException: getOutputStream() has already been
called for this response

        at
org.apache.coyote.tomcat5.CoyoteResponse.getWriter(CoyoteResponse.java:6
19)

        at
org.apache.coyote.tomcat5.CoyoteResponseFacade.getWriter(CoyoteResponseF
acade.java:181)

        at
org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:143)

        at
org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:1
36)

        at
org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:1
95)

        at
org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspF
actoryImpl.java:120)

        at
org.apache.jasper.runtime.JspFactoryImpl.access$100(JspFactoryImpl.java:
42)

 

 

I think this is likely to be something to do with committing the
response twice or something isn't it? (I've never been great on the
servlet spec so please bare with me ;-( ). I guess what I'm asking is;

 

-          Am I trying to re-direct the user at the right stage? Ie in
my filter... or do I need to go back and build functionality into my
business delegate (remoting service), then use
RequestContext.getHttpServletResponse() to send the error?

-          Or is there some way of editing the request or response while
still in the filter to stop it continuing onward to the gateway servlet?

-          Or have I completely got the wrong end of the stick?

 

Thanks a lot for any help or advice anyone can provide

Cheers

Dave

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Openamf-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openamf-user