Open axelGschaider opened 11 years ago
P.S.: currently I'm of course refactoring so I can just call the needed functions directly without need for a forward (makes the code easier to read too :) ). But this will work for 80% of the cases without substantial work . . .
Hi,
can you create a minimal example including the ScalatraBootstrap and your controllers?
Regards, Stefan
On 02.08.2013 14:27, Axel Gschaider wrote:
I'm in progress of switching from 2.0 to 2.2
In some legacy code we make heavy use of this function ( obviously copied from this stackoverflow thread http://stackoverflow.com/questions/6786219/scalatra-how-do-we-do-an-internal-redirect-forward-of-request ):
`def forward(route:String) { logger.debug("forwarding to " + route)
|// this is where "it really happens" getServletContext.getRequestDispatcher(route).forward(request, response)
// added these lines in the process of debugging logger.debug("forwarded. Halting.") halt() logger.debug("you should never read this!") |
}`
when calling this code with the parameter "/account/login" I get the following loging: DEBUG-08/02 14:07:50,523 PlanController - forwarding to /account/login DEBUG-08/02 14:07:50,524 AccountController - got context account INFO -08/02 14:07:50,524 AccountController - start :GET /login from 127.0.0.1 DEBUG-08/02 14:07:50,525 AccountController - scalatraParams:Map() INFO -08/02 14:07:50,530 AccountController - redirect to : / INFO -08/02 14:07:50,531 PlanController - end :GET /login DEBUG-08/02 14:07:50,532 PlanController - forwarded. Halting. where in the AccountController I have these handlers:
`get("/login") { logger.debug("welcome to the login my friend. How can I help you?") // and other code }
// added this handler for debugging purposes get("/login/") { logger.debug("WTF?????") }`
As you can see I never reach the correct handler which is something that worked before the switch. I'm not happy about working directly with |javax.servlet.ServletContext| and I believe it's the root of the problem. But this is the functionality that I have to provide at the moment. Is there a correct way to do a forward to another controller/handler?
Regards Axel
— Reply to this email directly or view it on GitHub https://github.com/scalatra/scalatra/issues/287.
hi Stefan,
I will gladly do so. But I'm leaving for a holiday and will not be back until middle of August. For now I solved the situation by refactoring and type-tricks which resulted in overall nicer code :) But I'll try to give you a minimal example as soon as I get back.
Regards Axel
I'm in the progress of switching from 2.0 to 2.2
In some legacy code we make heavy use of this function ( obviously copied from this stackoverflow thread ):
when calling this code with the parameter
"/account/login"
I get the following loging:where in the AccountController I have these handlers:
As you can see I never reach the correct handler which is something that worked before the switch. I'm not happy about working directly with
javax.servlet.ServletContext
and I believe it's the root of the problem. But this is the functionality that I have to provide at the moment. Is there a correct way to do a forward to another controller/handler?Regards Axel