I seriously cannot find the correct way to do this.
I have this method and it works, but it seems kind of a work around to do something so basic.
FacesContext context = FacesContext.getCurrentInstance();
String baseURL = context.getExternalContext().getRequestContextPath();
String startDateString = sdf.format(startDate);
String endDateString = sdf.format(endDate);
String url = baseURL + "/Excel?pkgLineId="+selectedPkgLine.getPkgLineId()+"&dateStart=" + startDateString + "&dateEnd=" + endDateString;
try {
String encodeURL = context.getExternalContext().encodeResourceURL(url);
context.getExternalContext().redirect(encodeURL);
} catch (Exception e) {
} finally {
context.responseComplete();
}
I have also read that calling servlets is not considered best practice. What if I moved my servlet to a web service? How would I go about calling that? Thanks for any help.