| | |
| | | |
| | | import java.io.IOException; |
| | | import javax.servlet.ServletException; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.markdownj.MarkdownProcessor; |
| | | |
| | | /** |
| | | * |
| | |
| | | public class MarkdownServlet extends WbxServlet { |
| | | |
| | | |
| | | /** |
| | | * Handles the HTTP <code>GET</code> method. |
| | | * |
| | | * @param request servlet request |
| | | * @param response servlet response |
| | | * @throws ServletException if a servlet-specific error occurs |
| | | * @throws IOException if an I/O error occurs |
| | | */ |
| | | @Override |
| | | protected void doGet(HttpServletRequest request, HttpServletResponse response) |
| | | throws ServletException, IOException { |
| | | String contextPath = request.getContextPath(); |
| | | if(HOME_CTX.equals(contextPath)) { |
| | | String userName = getUserName(request); |
| | | if (userName != null) { |
| | | String urlUser = getUrlUser(request, userName); |
| | | if(userName.equals(urlUser)) { |
| | | seiteAusgeben(request, response); |
| | | } else { |
| | | logger.fine("Wrong user."); |
| | | } |
| | | } else { |
| | | logger.fine("Missing login."); |
| | | } |
| | | } else { |
| | | seiteAusgeben(request, response); |
| | | } |
| | | } |
| | | |
| | | private void seiteAusgeben(HttpServletRequest request, HttpServletResponse response) { |
| | | protected void seiteAusgeben(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { |
| | | |
| | | CustomResponseWrapper wrapper = new CustomResponseWrapper(response); |
| | | super.doGet(request, wrapper); |
| | | String responseContent = wrapper.getResponseContent(); |
| | | ServletOutputStream out = response.getOutputStream(); |
| | | MarkdownProcessor p = new MarkdownProcessor(); |
| | | out.print(p.markdown(responseContent)); |
| | | } |
| | | |
| | | } |