/*
* JSPhandler.java
*
*
* Copyright (c) 2003 Rimfaxe ApS (www.rimfaxe.com).
* All rights reserved.
*
* This package is written by Lars Andersen <lars@rimfaxe.com>
* and licensed by Rimfaxe ApS.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by Rimfaxe ApS
(www.rimfaxe.com)"
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "Rimfaxe", "Rimfaxe Software", "Lars Andersen" and
* "Rimfaxe WebServer" must not be used to endorse or promote products
* derived from this software without prior written permission. For written
* permission, please contact info@rimfaxe.com
*
* 5. Products derived from this software may not be called "Rimfaxe"
* nor may "Rimfaxe" appear in their names without prior written
* permission of the Rimfaxe ApS.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
package com.rimfaxe.webserver.servletapi.jsp;
import java.util.*;
import com.rimfaxe.webserver.VirtualHost;
import com.rimfaxe.webserver.WebContext;
import org.apache.naming.resources.Resource;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import org.apache.naming.resources.ResourceAttributes;
/**
*
* @author Lars Andersen
*/
public class JSPhandler
{
String cls = "";
String jsp_page = "";
/** Creates a new instance of JSPhandler */
public JSPhandler()
{
}
public JSPclass getServletClass(VirtualHost vh, WebContext webcontext, String urlpath)
{
// strip off trailing parameters
StringTokenizer tkz = new StringTokenizer(urlpath,"?&",false);
jsp_page = tkz.nextToken();
//System.out.println("JSP page : "+jsp_page);
ResourceAttributes tempAttrs = webcontext.getResourceAttributes(jsp_page);
if (tempAttrs==null)
{
//System.out.println("Can't find info on JSP");
return null;
}
//System.out.println("Get last-modified");
com.rimfaxe.util.Calendar last_modified = new com.rimfaxe.util.Calendar(tempAttrs.getLastModifiedDate());
//System.out.println("Create JSPclass");
JSPclass jsp_class = new JSPclass(vh.getName(),last_modified, jsp_page);
jsp_class = webcontext.getJSPstore().lookupJSP(jsp_class);
return jsp_class;
}
}