Passing data between multiple requests

500 views
Skip to first unread message

J0t1

unread,
Aug 6, 2015, 2:38:42 PM8/6/15
to vert.x
Hello ,
We are developing a web application using Vertx. On click of button on the html page(developed using thymeleaf) the page is submitted to a url (/action/dosomething) , this call is handled  by one of the handlers configured in vertx vertical.
router.route("/action/*").handler(this::handlePageAction);
handlePageAction method acts as a controller and determines which html page to call next based on some conditions. For forwarding the request to next html page this is the code we are using:
routingContext.response().putHeader("location", "/view/"+htmlPageName).setStatusCode(302).end();
I have another handler in same vertical which takes care of rendering the html page requested using ThymeleafTemplateHandler
router.route("/view/*").handler(templateHandler);

I need to display some dynamic data in the requested html page and need to set that data in routing context which i can then access in thymeleaf. But problem I am facing is that any data i set in routing context before calling routingContext.response().putHeader("location",xyz) is getting lost. I read in the documentation that routingContext is only available till the response is written. 
I have 2 questions here
1. Is these any other way of forwarding requests in vertx which also allows me to pass parameters in the request?
2. Is there any other mechanism of passing data between multiple requests(apart from using sessions)

Will appreciate any pointers/help on this. Thanks !



Mumuney Abdlquadri

unread,
Aug 7, 2015, 4:40:22 PM8/7/15
to ve...@googlegroups.com
have you tried this
http://vertx.io/docs/vertx-web/java/#_capturing_path_parameters
> --
> You received this message because you are subscribed to the Google Groups
> "vert.x" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vertx+un...@googlegroups.com.
> Visit this group at http://groups.google.com/group/vertx.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/vertx/fa0c6e7f-c9d4-4c13-a2ee-197cce3e15ab%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

J0t1

unread,
Aug 10, 2015, 3:54:49 AM8/10/15
to vert.x
Hi Mamuney,

Thank you for your response. I have tried sending the parameters as query string with the requested url e.g.

routingContext.response().putHeader("location", "/view/"+htmlPageName+"?param1=someData").setStatusCode(302).end();

This works just fine but i am looking for some way where the parameters I pass are not visible in the browser url.  Kind of making a POST request instead of GET may be !

Any pointers?

J0t1

unread,
Aug 10, 2015, 4:31:17 AM8/10/15
to vert.x
Is there any way to forward a request to different handler in same vertical?
Reply all
Reply to author
Forward
0 new messages