tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yunfeng Hou <houy...@yahoo.com>
Subject jasper package
Date Mon, 19 Aug 2002 03:46:46 GMT
Jasper has command line option to set package name,
but not true for JspServlet, I made some change to
give user a chance to set the packageName in the
servlet init parameter.

What I have done is add getPackageName to Options
class, modify JspServlet and ClassLoader to recognize
this parameter, remove the hard-coded default package
name Constants.JSP_PACKAGE_NAME.

diff  ./embededservletoptions.java
\Jetty-4.1.0RC1\src\org\apache\jasper/embededservletoptions.java
81,83d80
< 	
< 	/* the package name of the jsp class generated */
< 	public String packageName =
Constants.JSP_PACKAGE_NAME;
350,354d346
<         
<         String tmpStr =
config.getInitParameter("packageName");
<         if (tmpStr != null && ! "".equals(tmpStr)) {
<        		packageName = tmpStr;
<         }
360,366d351
< 	/**
< 	 * @see org.apache.jasper.Options#getPackageName()
< 	 */
< 	public String getPackageName() {
< 		return packageName;
< 	}
< 
diff  ./jspc.java
\Jetty-4.1.0RC1\src\org\apache\jasper/jspc.java
753,759d752
< 	/**
< 	 * @see org.apache.jasper.Options#getPackageName()
< 	 */
< 	public String getPackageName() {
< 		return targetPackage;
< 	}
< 
diff  ./options.java
\Jetty-4.1.0RC1\src\org\apache\jasper/options.java
150,155d149
<     
<     /**
<      * Package name of generated class.
<      */
<     public String getPackageName();
<     

diff  ./jasperloader.java
\Jetty-4.1.0RC1\src\org\apache\jasper\servlet/jasperloader.java
191,206c191,202
< 	//if( !name.startsWith(Constants.JSP_PACKAGE_NAME)
) {
< 			try {
< 				    ClassLoader classLoader = null;
< 				if (System.getSecurityManager() != null) {
< 				         classLoader =
(ClassLoader)AccessController.doPrivileged(privLoadClass);
< 				    } else {
< 				    classLoader =
Thread.currentThread().getContextClassLoader();
< 				    }
< 				    clazz = classLoader.loadClass(name);
< 				if( resolve )
< 				resolveClass(clazz);
< 			    return clazz;
< 			} catch (ClassNotFoundException e) {
< 				// context class load can not find the class,
try jsp class loader
< 			}
< 	//}
---
> 	if( !name.startsWith(Constants.JSP_PACKAGE_NAME) )
{
>             ClassLoader classLoader = null;
> 	    if (System.getSecurityManager() != null) {
>                  classLoader =
(ClassLoader)AccessController.doPrivileged(privLoadClass);
>             } else {
> 	        classLoader =
Thread.currentThread().getContextClassLoader();
>             }
>             clazz = classLoader.loadClass(name);
> 	    if( resolve )
> 		resolveClass(clazz);
> 	    return clazz;
> 	}
209,210c205,207
< 	//if( name.startsWith(Constants.JSP_PACKAGE_NAME)
&& name.endsWith(className) ) {
< 	    String classFile =
name.substring(name.lastIndexOf(".") + 1) + ".class";
---
> 	if( name.startsWith(Constants.JSP_PACKAGE_NAME +
"." + className) ) {
> 	    String classFile =
name.substring(Constants.JSP_PACKAGE_NAME.length()+1)
+
> 		".class";
226c223
< 	//}
---
> 	}
diff  ./jspservlet.java
\Jetty-4.1.0RC1\src\org\apache\jasper\servlet/jspservlet.java
127d126
< 	
249,251d247
< 	/* added by houyunf to provide package support */
< 	private String packagePath = "";
< 
270,275c266
< 	
< 	/* added by houyunf to support package name */
< 	packagePath = options.getPackageName();
< 	packagePath = packagePath.replace('.', '/');
< 	
< 	
---
> 
348,349c339
< 		String basePackage = 
options.getPackageName()+".";			// modified by houyunf
< //		"org.apache.jasper.";
---
> 		String basePackage = "org.apache.jasper.";
533,537d522
<         String jspPackage = jspUri.substring(0,
jspUri.lastIndexOf("/"));
<         if ("".equals(jspPackage))
<         	jspPackage = null;
<         if (jspPackage != null ) 
<         	jspPackage =
jspPackage.substring(1).replace('/', '.');
542c527
<                 outURI = outURI + packagePath;
---
>                 outURI = outURI +
jspUri.substring(1,jspUri.lastIndexOf("/")+1);
544,545c529
<             	outURI = outURI + "/" + packagePath;
<             outURI = outURI +
jspUri.substring(0,jspUri.lastIndexOf("/")+1);
---
>                 outURI = outURI +
jspUri.substring(0,jspUri.lastIndexOf("/")+1);;
559,565d542
<         String packageName =
options.getPackageName();
<         if (packageName == null ||
"".equals(packageName)) 
<         	packageName = jspPackage;
<         else if (jspPackage != null)
<         	packageName = packageName + "." +
jspPackage;
<         ctxt.setServletPackageName(packageName);
< 
601c578
< 			packageName + "." + ctxt.getServletClassName());
---
> 			Constants.JSP_PACKAGE_NAME + "." +
ctxt.getServletClassName());


_________________________________________________________
Do You Yahoo!? 
新鲜到底,娱乐到家 - 雅虎推出免费娱乐电子周报!
http://cn.ent.yahoo.com/newsletter/index.html

_________________________________________________________
Do You Yahoo!? 
新鲜到底,娱乐到家 - 雅虎推出免费娱乐电子周报!
http://cn.ent.yahoo.com/newsletter/index.html

_________________________________________________________
Do You Yahoo!? 
新鲜到底,娱乐到家 - 雅虎推出免费娱乐电子周报!
http://cn.ent.yahoo.com/newsletter/index.html
Mime
View raw message