Re: Appnding session id to the URL

Splash Forums PrettyFaces Users Appnding session id to the URL Re: Appnding session id to the URL


So there is an issue with URL-encoding entire URLs, which is that the path and the query need different forms of encoding. To solve this, you can use the AddressBuilder module from Rewrite. (Don’t mind the Alpha, this part is simple and stable.) This is a perfect use-case for AddressBuilder, you should be able to replace all of the StringBuilder code in your URLHandlerBean.


You’ll want to do something like this:

AddressBuilderQuery builder = AddressBuilder.begin().protocol("http").host("localhost")
.path("/{p}").setEncoded("p", "a%20b")
.query("trip", getUrlHandlerBean().getTrip())
.query("origin", getUrlHandlerBean().getOrigin())
.query("destination", getUrlHandlerBean().getDestination())
.query("depart_date", getUrlHandlerBean().getDepart_date());

if(null!=getUrlHandlerBean().getArrival_date()) {
builder.query("arrival_date", getUrlHandlerBean().getArrival_date());
if(null!=getUrlHandlerBean().getDirect_flight()) {
builder.query"direct_flight", getUrlHandlerBean().getDirect_flight());
if(null!=getUrlHandlerBean().getClasstype()) {
builder.query("classtype", getUrlHandlerBean().getClasstype());

And so on….

But don’t use URLEncoder when you set your values. If you use AddressBuilder the way I’ve shown above, your values will automatically be encoded when the Address is built. No worries to you :)

Let me know how it goes. You’ll still probably want to remove the sessionID if it shows up.