001    /*
002     * Copyright (c) 2005 Henri Sivonen
003     *
004     * Permission is hereby granted, free of charge, to any person obtaining a 
005     * copy of this software and associated documentation files (the "Software"), 
006     * to deal in the Software without restriction, including without limitation 
007     * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
008     * and/or sell copies of the Software, and to permit persons to whom the 
009     * Software is furnished to do so, subject to the following conditions:
010     *
011     * The above copyright notice and this permission notice shall be included in 
012     * all copies or substantial portions of the Software.
013     *
014     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
015     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
016     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
017     * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
018     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
019     * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
020     * DEALINGS IN THE SOFTWARE.
021     */
022    
023    package fi.iki.hsivonen.verifierservlet;
024    
025    import java.io.IOException;
026    
027    import javax.servlet.ServletException;
028    import javax.servlet.http.HttpServlet;
029    import javax.servlet.http.HttpServletRequest;
030    import javax.servlet.http.HttpServletResponse;
031    
032    import org.apache.log4j.Logger;
033    
034    import fi.iki.hsivonen.xml.PrudentHttpEntityResolver;
035    
036    /**
037     * @version $Id: VerifierServlet.java,v 1.11 2006/10/26 14:06:59 hsivonen Exp $
038     * @author hsivonen
039     */
040    public class VerifierServlet extends HttpServlet {
041        /**
042         * 
043         */
044        private static final long serialVersionUID = 7811043632732680935L;
045        private static final Logger log4j = Logger.getLogger(VerifierServlet.class);
046    
047        static {
048            PrudentHttpEntityResolver.setParams(5000, 5000, 100);
049            PrudentHttpEntityResolver.setUserAgent(System.getProperty("fi.iki.hsivonen.verifierservlet.version", "VerifierServlet-RELAX-NG-Validator/2.x (http://hsivonen.iki.fi/validator/)"));
050        }
051        
052        /**
053         * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
054         */
055        protected void doGet(HttpServletRequest request, HttpServletResponse response)
056                throws ServletException, IOException {
057            String pathInfo = request.getPathInfo();
058            log4j.debug("pathInfo: " + pathInfo);
059            if ("/".equals(pathInfo)) {
060                new VerifierServletTransaction(request, response).doGet();
061            } else if ("/html5/".equals(pathInfo)) {
062                new Html5ConformanceCheckerTransaction(request, response).doGet();
063            } else {
064                response.sendError(HttpServletResponse.SC_NOT_FOUND);
065            }
066        }
067    }