get jsp response as a string inside servlet
问题 Is there a way to get response from a jsp file as a String inside servlet. Something like protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String section1 = getResponseFromJSP(); // do something else ... sendMailToUser(section1); } I'm using Servlet API 2.4 and java 1.4 回答1: A better solution might be to use another template engine like freemarker or velocity, which are independent of the servlet api and more suited for