There are several ways to do this. Doing it in JSP is a bit nasty.
As already mentioned you can use a Servlet and inject/load your variables in there. Eg by accessing the session context:
MyBean myBean = (MyBean)FacesContext.getCurrentInstance()
.getExternalContext().getSessionMap().get("myBean");
Or you can output it to the HTTP Response from a method in your Backing Bean. Eg:
try {
String xml = "<person>damian</person>";
FacesContext ctx = FacesContext.getCurrentInstance();
final HttpServletResponse resp = (HttpServletResponse)ctx.getExternalContext().getResponse();
resp.setContentType("text/xml");
resp.setContentLength(xml.length());
resp.getOutputStream().write(xml.getBytes());
resp.getOutputStream().flush();
resp.getOutputStream().close();
ctx.responseComplete();
} catch (IOException e) {
e.printStackTrace();
}
Or if you are using Facelets you can set the response type in the <f:view>
tag.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…