package com.decker.Essentials;

import java.io.IOException;
import java.io.OutputStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.decker.Essentials.Category.Category;
import com.decker.Essentials.User.User;

public class Center extends org.sipc.se.plugin.PluginImpl
{

    Category category;

    public Center()
    {
	super();
	this.category = Category.getInstance();
    }

    @Override
    public void getResponse(HttpServletRequest request, HttpServletResponse response)
    {
	String url = request.getRequestURI();
	String target;
	Matcher matcher = Pattern.compile("(?<=Essentials/).*").matcher(url);
	if (matcher.find())
	{
	    target = matcher.group(0);
	} else
	{
	    target = "Default.html";
	}
	target = target.replaceAll("\\?.*", null);
	OutputStream stream;
	try
	{
	    stream = response.getOutputStream();
	    byte[] resource = null;

	    if (target.matches(".*.exec"))
	    {
		// dynamic generate
		User current = new User(request,response);
		response.setContentType("application/json");
		resource = Command.Execute(current, request, response);
	    } else
	    {
		// static resource
		resource = ResourceManager.getInstance().getResource("Content/" + target);
		if (resource.length == 0)
		{
		    response.setStatus(404);
		}
	    }

	    stream.write(resource);

	} catch (IOException e)
	{

	}

    }

    @Override
    public String getUrl()
    {
	return "~/Essentials";
    }

    @Override
    public boolean onEnable()
    {
	// TODO Auto-generated method stub
	return true;
    }
}

@@ -1506,16 +1506,86 @@
 e)%0D%0A%09%7B%0D%0A
+%09    e.printStackTrace();%0D%0A%09    response.setStatus(500);%0D%0A%09    return;
 %0D%0A%09%7D%0D%0A%0D%0A

Add exception when processing request