I would like to add an apostrophe to a file name. The file is generated on my Java server and sent back via a Faces-based HTTPServletResponse object. Whith the code below, the filename ends up being “french_filename.txt”. What is the correct way to encode the apostrophe to ensure that the filename is sent down correctly?
HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
response.reset();
response.setContentType("application/txt");
response.setHeader("Content-disposition", "attachment; filename=\"french'filename.txt\"");
To work in both IE and Chrome, I found that “french\’file” worked best.