/** * Peforms the processing associated with this action. * * @param request the HttpServletRequest instance * @param response the HttpServletResponse instance * @return the name of the next view */ public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException { Blog blog = (Blog) request.getAttribute(Constants.BLOG_KEY); StringBuffer query = new StringBuffer(); addTerm(query, "title", request.getParameter("title")); addTerm(query, "body", request.getParameter("body")); addTerms(query, "category", request.getParameterValues("category")); addTerm(query, "author", request.getParameter("author")); String tags = request.getParameter("tags"); if (tags != null) { String s[] = tags.split(","); for (int i = 0; i < s.length; i++) { s[i] = Tag.encode(s[i].trim()); } addTerms(query, "tag", s); } try { String encodedQuery = URLEncoder.encode(query.toString(), blog.getCharacterEncoding()); return new ForwardView("/search.action?query=" + encodedQuery); } catch (UnsupportedEncodingException uee) { throw new ServletException(uee); } }
/** * Gets the content type of this view. * * @return the content type as a String */ public String getContentType() { Blog blog = (Blog) getModel().get(Constants.BLOG_KEY); return "application/xml; charset=" + blog.getCharacterEncoding(); }