1 25 package org.snipsnap.net; 26 27 import org.snipsnap.snip.Snip; 28 import org.snipsnap.snip.SnipLink; 29 import org.snipsnap.snip.SnipSpaceFactory; 30 import org.snipsnap.app.Application; 31 import org.snipsnap.config.Configuration; 32 33 import javax.servlet.RequestDispatcher ; 34 import javax.servlet.ServletException ; 35 import javax.servlet.http.HttpServlet ; 36 import javax.servlet.http.HttpServletRequest ; 37 import javax.servlet.http.HttpServletResponse ; 38 import java.io.IOException ; 39 import java.util.Map ; 40 41 46 public class CommentViewServlet extends HttpServlet { 47 48 public void doGet(HttpServletRequest request, HttpServletResponse response) 49 throws IOException , ServletException { 50 51 String name = request.getPathInfo(); 52 if (null == name) { 53 Configuration config = Application.get().getConfiguration(); 54 55 response.sendRedirect(config.getUrl("/space/"+Application.get().getConfiguration().getStartSnip())); 56 return; 57 } else { 58 name = name.substring(1); 59 } 60 61 Snip snip = SnipSpaceFactory.getInstance().load(name.replace('+', ' ')); 62 if (null == snip) { 64 System.err.println("Snip does not exist: name=" + name); 65 snip = SnipSpaceFactory.getInstance().load("snipsnap-notfound"); 66 } 67 68 Application app = Application.get(); 69 Map params = app.getParameters(); 70 params.put("viewed", snip); 71 params.put("RSS", params.get("RSS") + "?snip=" + snip.getNameEncoded()); 72 73 request.setAttribute("snip", snip); 74 request.setAttribute("URI", request.getRequestURI()); 75 RequestDispatcher dispatcher = request.getRequestDispatcher("/exec/comment.jsp"); 76 dispatcher.forward(request, response); 77 } 78 79 } 80 | Popular Tags |