001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.servlet;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.util.Portal;
020    import com.liferay.portal.util.PortalUtil;
021    
022    import java.io.IOException;
023    
024    import javax.servlet.RequestDispatcher;
025    import javax.servlet.ServletContext;
026    import javax.servlet.ServletException;
027    import javax.servlet.http.HttpServlet;
028    import javax.servlet.http.HttpServletRequest;
029    import javax.servlet.http.HttpServletResponse;
030    
031    /**
032     * @author David Truong
033     */
034    public class RobotsServlet extends HttpServlet {
035    
036            @Override
037            public void service(
038                            HttpServletRequest request, HttpServletResponse response)
039                    throws IOException, ServletException {
040    
041                    try {
042                            String redirect = Portal.PATH_MAIN + "/layouts_admin/robots";
043    
044                            ServletContext servletContext = getServletContext();
045    
046                            RequestDispatcher requestDispatcher =
047                                    servletContext.getRequestDispatcher(redirect);
048    
049                            requestDispatcher.forward(request, response);
050                    }
051                    catch (Exception e) {
052                            _log.error(e, e);
053    
054                            PortalUtil.sendError(
055                                    HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e, request,
056                                    response);
057                    }
058            }
059    
060            private static Log _log = LogFactoryUtil.getLog(RobotsServlet.class);
061    
062    }