Hello,I am writing an amp which will do a search on the repository and return some data.I has to be exposed as an http get. So I am using the CommandServlet but instead of returning the html content type, I would like to return an xml document.How do I solve this when adding a servlet to web.xml is not an option… .This is a code sniplet of the CommandServlet. As you can see, it overwrites the content type after it returns from the processor.Maybe this line should not be there in order to make the CommandServlet more useful?…
protected void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
…
((ExtCommandProcessor)processor).process(serviceRegistry, req, res, command);
…
String returnPage = req.getParameter(ARG_RETURNPAGE);
if (returnPage != null && returnPage.length() != 0)
{
if (logger.isDebugEnabled())
logger.debug("Redirecting to specified return page: " + returnPage);
res.sendRedirect(returnPage);
}
else
{
if (logger.isDebugEnabled())
logger.debug("No return page specified, displaying status output.");
//I'm talking about this line of code …
res.setContentType("text/html");
// request that the processor output a useful status message
PrintWriter out = res.getWriter();
processor.outputStatus(out);
out.close();
}
}
…
}