java - Play 2.2.2 (Scala), how to handle HttpServletRequests -
i new play , scala, , stuck problem, goes like: simple explanation,
www.somesite.com/redirectedfoo //points below controller def redirectedfoo = action{ //the http request needs traced here, //and needs accessed java api method val obj=new samplemethod(--need http request obj argument--) //my problem play request , http request totally different 'objects', //and above method uses httpservletrequest obj, how handled in play }
sorry couldn't provide proper explanation,
for purposes, play wrong place be. play designed able run outside of servlet containers, , therefore implements api http requests not conform @ servlet api.
you have 2 options:
write own function converts
play.api.mvc.request
own implementation ofjavax.servlet.http.httpservletrequest
. althoughhttpservletrequest
quite big interface dependencies on more big classes, information contained in playrequest
should enough constructhttpservletrequest
. depending on use might leave or methods unimplemented reduce effort. check out this class example.if run play 2 application servlet , method allows, can write own servlet application runs in front of play application. call methods servlet api need when required, , forwards request play 2 application when not needed.
these both quite hacky might acceptable single use case. if need integration servlet apis or depend on lot of other code does, need ask whether play 2 right choice. play 2 can support java ee technology, servlet api not support well. if want use servlet api modern scala http framework, might want @ spray , servlet support.
Comments
Post a Comment