application.setContext(new ServletContext(this, application, container.getContext()));
	public HttpServerHelper getServer(HttpServletRequest request)	{		HttpServerHelper result = this.helper;		if (result == null)		{			synchronized (ServerServlet.class)			{				// Find the attribute name to use to store the server reference				String serverAttributeName = getInitParameter(NAME_SERVER_ATTRIBUTE,						NAME_SERVER_ATTRIBUTE_DEFAULT);				// Look up the attribute for a target				result = (HttpServerHelper) getServletContext().getAttribute(						serverAttributeName);				if (result == null)				{					// Try to instantiate a new target application					// First, find the application class name					String applicationClassName = getInitParameter(NAME_APPLICATION_CLASS,							null);					if (applicationClassName != null)					{						try						{							// Load the application class using the given class name							Class targetClass = Class.forName(applicationClassName);							// First, let's locate the closest container							Container container = new Container();							Server server = new Server(container.getContext(), (List<Protocol>)null, request									.getLocalAddr(), request.getLocalPort(), container); 							result = new HttpServerHelper(server); 							getServletContext().setAttribute(NAME_SERVER_ATTRIBUTE, result);							if (container != null)							{								// Create a new instance of the application class								Application application = (Application) targetClass										.getConstructor(Context.class).newInstance(												container.getContext());								// Attach the application								String uriPattern = request.getContextPath()										+ request.getServletPath();								container.getDefaultHost().attach(uriPattern, application);								// Starts the target Restlet								result.start();							}							else							{								log("[Noelios Restlet Engine] - The Restlet container couldn't be instantiated.");							}						}						catch (ClassNotFoundException e)						{							log(									"[Noelios Restlet Engine] - The ServerServlet couldn't find the target class. Please check that your classpath includes "											+ applicationClassName, e);						}						catch (InstantiationException e)						{							log(									"[Noelios Restlet Engine] - The ServerServlet couldn't instantiate the target class. Please check this class has an empty constructor "											+ applicationClassName, e);						}						catch (IllegalAccessException e)						{							log(									"[Noelios Restlet Engine] - The ServerServlet couldn't instantiate the target class. Please check that you have to proper access rights to "											+ applicationClassName, e);						}						catch (Exception e)						{							log(									"[Noelios Restlet Engine] - The ServerServlet couldn't start the target Restlet.",									e);						}					}					else					{						log("[Noelios Restlet Engine] - The ServerServlet couldn't find the target class name. Please set the initialization parameter called "								+ NAME_APPLICATION_CLASS);					}				}				this.helper = result;			}		}		return result;	}