I have a Java class (Servlet). I need to display the source code; whatever the content in the servlet. This is totally for testing purpose
I know that I could do this through appending to a StringBuffer object, but I have more lines. And another alternative it write to a file. It's again the same. I should write every single line using a file writer. Is there a simple approach to this?
How can I achieve this?
public class TimeZoneValidator extends HttpServlet {
private static final long serialVersionUID = 1L;
public TimeZoneValidator() {
    super();
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    //I need this code to be displayed in my JSP(index.jsp) file
    request.setAttribute("oldNumberOfNghtsCalc", oldNumberOfNghtsCalc);
    request.setAttribute("newNumberOfNghtsCalc", newNumberOfNghtsCalc);
    RequestDispatcher requestDispatcher = request.getRequestDispatcher("/index.jsp");
    requestDispatcher.forward(request, response);
}
}
 
    