com.intouch.processor.RequestProcessor.java Source code

Java tutorial

Introduction

Here is the source code for com.intouch.processor.RequestProcessor.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.intouch.processor;

import com.intouch.action.Processor;
import java.io.InputStream;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import org.json.simple.JSONObject;

/**
 *
 * @author ?
 */
public class RequestProcessor {

    public JSONObject processRequest(HttpServletRequest request) throws Exception {
        InputStream inputStream = request.getServletContext()
                .getResourceAsStream("/WEB-INF/resourse/properties/prop.properties");
        Properties properties = new Properties();
        properties.load(inputStream);
        Class cls = Class.forName(properties.getProperty(request.getParameter("method")));
        Processor processor = (Processor) cls.newInstance();
        inputStream.close();
        return processor.processRequest(request.getParameterMap());
    }
}