Re: Appnding session id to the URL

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

#23317

Carolina
Member

Hi Christian,

Here is the complete code to create URL parameters.

StringBuilder urlbuilder = new StringBuilder();

urlbuilder.append("trip=");
urlbuilder.append(getUrlHandlerBean().getTrip());

urlbuilder.append("&origin=");
urlbuilder.append(getUrlHandlerBean().getOrigin());

urlbuilder.append("&destination=");
urlbuilder.append(getUrlHandlerBean().getDestination());

urlbuilder.append("&depart_date=");
urlbuilder.append(getUrlHandlerBean().getDepart_date());

if(null!=getUrlHandlerBean().getArrival_date()){

urlbuilder.append("&arrival_date=");
urlbuilder.append(getUrlHandlerBean().getArrival_date());
}
if(null!=getUrlHandlerBean().getDirect_flight()){

urlbuilder.append("&direct_flight=");
urlbuilder.append(getUrlHandlerBean().getDirect_flight());
}
if(null!=getUrlHandlerBean().getClasstype()){
urlbuilder.append("&classtype=");
urlbuilder.append(getUrlHandlerBean().getClasstype());
}
if(null!=getUrlHandlerBean().getRoom1()){

urlbuilder.append("&room1=");
urlbuilder.append(getUrlHandlerBean().getRoom1());
}
if(null!=getUrlHandlerBean().getRoom2()){

urlbuilder.append("&room2=");
urlbuilder.append(getUrlHandlerBean().getRoom2());
}
if(null!=getUrlHandlerBean().getRoom3()){

urlbuilder.append("&room3=");
urlbuilder.append(getUrlHandlerBean().getRoom3());
}
if(null!=getUrlHandlerBean().getRoom4()){
urlbuilder.append("&room4=");
urlbuilder.append(getUrlHandlerBean().getRoom4());
}
if(null!=getUrlHandlerBean().getRoom5()){
urlbuilder.append("&room5=");
urlbuilder.append(getUrlHandlerBean().getRoom5());
}
if(null!=getUrlHandlerBean().getRoom6()){

urlbuilder.append("&room6=");
urlbuilder.append(getUrlHandlerBean().getRoom6());
}
if(null!=getUrlHandlerBean().getTraveltype()){

urlbuilder.append("&traveltype=");
urlbuilder.append(getUrlHandlerBean().getTraveltype());
}
String sessionId = FacesUtils.getCurrentSession().getId();

String url = urlbuilder.toString();
url.replaceAll(sessionId, "");

FacesUtils.getFacesContext().getExternalContext().redirect(FacesUtils.getFacesContext().
getExternalContext().encodeActionURL(FacesUtils.getFacesContext().getExternalContext().getRequestContextPath()
+ "/pages/package/flighthotel/flightPlusHotelResults.xhtml?"+url));