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:

  1. write own function converts play.api.mvc.request own implementation of javax.servlet.http.httpservletrequest. although httpservletrequest quite big interface dependencies on more big classes, information contained in play request should enough construct httpservletrequest. depending on use might leave or methods unimplemented reduce effort. check out this class example.

  2. 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

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -