commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "dion gillard (JIRA)" <commons-...@jakarta.apache.org>
Subject [jira] Updated: (JELLY-177) In JellyServlet, the procedure used to determine the script's location is too simplistic
Date Sun, 06 Nov 2005 06:47:22 GMT
     [ http://issues.apache.org/jira/browse/JELLY-177?page=all ]

dion gillard updated JELLY-177:
-------------------------------

    Fix Version: 1.0.1
                     (was: 1.0-RC2)
    Description: 
In JellyServlet, the procedure used to determine the script's location is too simplistic;
it misses simple cases like the a *.jelly servlet-mapping.

I suggest replacing the getScript method with something like (taken in part from the Freemarker
servlet):

protected URL getScript(HttpServletRequest req)
			throws MalformedURLException {
		String scriptUrl = null;
		
		String includedPath = (String) req.getAttribute("javax.servlet.include.servlet_path");
		if (includedPath != null) { //This is the result of a RequestDispatcher include...
			String includedPathInfo = (String) req.getAttribute("javax.servlet.include.path_info");
			if (includedPathInfo != null) {
				scriptUrl = includedPathInfo;
			} else {
				scriptUrl = includedPath;
			}
		} else {
			scriptUrl = req.getParameter("script");
			if (scriptUrl == null) {
				scriptUrl = req.getPathInfo();
			}
			if (scriptUrl == null) {
				scriptUrl = req.getServletPath();
			}
		}
		
		URL url = getServletContext().getResource(scriptUrl);
		if (url == null) {
			throw new IllegalArgumentException("Invalid script url:"
					+ scriptUrl);
		}
		return url;
	}

  was:
In JellyServlet, the procedure used to determine the script's location is too simplistic;
it misses simple cases like the a *.jelly servlet-mapping.

I suggest replacing the getScript method with something like (taken in part from the Freemarker
servlet):

protected URL getScript(HttpServletRequest req)
			throws MalformedURLException {
		String scriptUrl = null;
		
		String includedPath = (String) req.getAttribute("javax.servlet.include.servlet_path");
		if (includedPath != null) { //This is the result of a RequestDispatcher include...
			String includedPathInfo = (String) req.getAttribute("javax.servlet.include.path_info");
			if (includedPathInfo != null) {
				scriptUrl = includedPathInfo;
			} else {
				scriptUrl = includedPath;
			}
		} else {
			scriptUrl = req.getParameter("script");
			if (scriptUrl == null) {
				scriptUrl = req.getPathInfo();
			}
			if (scriptUrl == null) {
				scriptUrl = req.getServletPath();
			}
		}
		
		URL url = getServletContext().getResource(scriptUrl);
		if (url == null) {
			throw new IllegalArgumentException("Invalid script url:"
					+ scriptUrl);
		}
		return url;
	}


> In JellyServlet, the procedure used to determine the script's location is too simplistic
> ----------------------------------------------------------------------------------------
>
>          Key: JELLY-177
>          URL: http://issues.apache.org/jira/browse/JELLY-177
>      Project: jelly
>         Type: Bug
>   Components: core / taglib.core
>     Versions: 1.0-beta-5, 1.0-RC1
>  Environment: Servlet, 1.0RC1
>     Reporter: Denis Robert
>     Priority: Minor
>      Fix For: 1.0.1

>
> In JellyServlet, the procedure used to determine the script's location is too simplistic;
it misses simple cases like the a *.jelly servlet-mapping.
> I suggest replacing the getScript method with something like (taken in part from the
Freemarker servlet):
> protected URL getScript(HttpServletRequest req)
> 			throws MalformedURLException {
> 		String scriptUrl = null;
> 		
> 		String includedPath = (String) req.getAttribute("javax.servlet.include.servlet_path");
> 		if (includedPath != null) { //This is the result of a RequestDispatcher include...
> 			String includedPathInfo = (String) req.getAttribute("javax.servlet.include.path_info");
> 			if (includedPathInfo != null) {
> 				scriptUrl = includedPathInfo;
> 			} else {
> 				scriptUrl = includedPath;
> 			}
> 		} else {
> 			scriptUrl = req.getParameter("script");
> 			if (scriptUrl == null) {
> 				scriptUrl = req.getPathInfo();
> 			}
> 			if (scriptUrl == null) {
> 				scriptUrl = req.getServletPath();
> 			}
> 		}
> 		
> 		URL url = getServletContext().getResource(scriptUrl);
> 		if (url == null) {
> 			throw new IllegalArgumentException("Invalid script url:"
> 					+ scriptUrl);
> 		}
> 		return url;
> 	}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message