All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.kut3.http.servlet.BaseServlet Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2019 Kut3Net.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.kut3.http.servlet;

import java.io.IOException;
import java.util.Enumeration;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.kut3.http.HttpMethod;

/**
 *
 */
public abstract class BaseServlet extends HttpServlet {

    @Override
    public final void service(ServletRequest req, ServletResponse res) 
            throws ServletException, IOException {
        
        super.service(req, res);
    }

    @Override
    protected final void service(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        
        switch (req.getMethod()) {
            case HttpMethod.POST:
                this.doPost(req, resp);
                break;

            case HttpMethod.GET:
                this.doGet(req, resp);
                break;

            case HttpMethod.PUT:
                this.doPut(req, resp);
                break;

            case HttpMethod.DELETE:
                this.doDelete(req, resp);
                break;
                
            default:
                resp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
                break;
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        
        resp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
    }

    @Override
    protected void doPut(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        
        resp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        
        resp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
    }

    @Override
    protected void doDelete(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        
        resp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
    }

    @Override
    protected final void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doHead(req, resp); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    protected final void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doOptions(req, resp); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    protected final void doTrace(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doTrace(req, resp); //To change body of generated methods, choose Tools | Templates.
    }
    
    @Override
    protected final Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    @Override
    public final void destroy() {
        super.destroy();
    }

    @Override
    public final String getInitParameter(String name) {
        return super.getInitParameter(name);
    }

    @Override
    public final Enumeration getInitParameterNames() {
        return super.getInitParameterNames();
    }

    @Override
    protected final long getLastModified(HttpServletRequest req) {
        return super.getLastModified(req);
    }

    @Override
    public final ServletConfig getServletConfig() {
        return super.getServletConfig();
    }

    @Override
    public final ServletContext getServletContext() {
        return super.getServletContext();
    }

    @Override
    public final String getServletInfo() {
        return super.getServletInfo();
    }

    @Override
    public final String getServletName() {
        return super.getServletName();
    }

    @Override
    public final void init() throws ServletException {
        super.init(); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public final void init(ServletConfig config) throws ServletException {
        super.init(config); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public final void log(String msg) {
        super.log(msg); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public final void log(String message, Throwable t) {
        super.log(message, t); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public final String toString() {
        return super.toString(); //To change body of generated methods, choose Tools | Templates.
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy