tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From man...@hyperreal.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/jasper/compiler ForwardGenerator.java IncludeGenerator.java
Date Tue, 19 Oct 1999 21:34:51 GMT
mandar      99/10/19 14:34:51

  Modified:    src/share/org/apache/jasper/compiler ForwardGenerator.java
                        IncludeGenerator.java
  Log:
  Handling jsp:param for jsp:include and jsp:forward.
  
  still todo:
  1) the RD stuff is not working correctly.
  2) "encoding" the parameters.
  
  Revision  Changes    Path
  1.2       +26 -21    jakarta-tomcat/src/share/org/apache/jasper/compiler/ForwardGenerator.java
  
  Index: ForwardGenerator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/ForwardGenerator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ForwardGenerator.java	1999/10/09 00:20:36	1.1
  +++ ForwardGenerator.java	1999/10/19 21:34:49	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/ForwardGenerator.java,v
1.1 1999/10/09 00:20:36 duncan Exp $
  - * $Revision: 1.1 $
  - * $Date: 1999/10/09 00:20:36 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/ForwardGenerator.java,v
1.2 1999/10/19 21:34:49 mandar Exp $
  + * $Revision: 1.2 $
  + * $Date: 1999/10/19 21:34:49 $
    *
    * ====================================================================
    * 
  @@ -93,46 +93,51 @@
       }
       
       public void generate(ServletWriter writer, Class phase) {
  +	boolean initial = true;
  +	String sep = "?";	
           writer.println("if (true) {");
           writer.pushIndent();
           writer.println("out.clear();");
  +	writer.println("String _jspx_qfStr = \"\";");
  +	
   	if (params.size() > 0) {
   	    Enumeration en = params.keys();
   	    while (en.hasMoreElements()) {
   		String key = (String) en.nextElement();
   		String []value = (String []) params.get(key);
  -
  +		if (initial == true) {
  +		    sep = "?";
  +		    initial = false;
  +		} else sep = "&";
  +		
   		if (value.length == 1 && JspUtil.isExpression(value[0]))
  -		    writer.println("request.setAttribute(\"" + key + "\", " +
  -				   JspUtil.getExpr(value[0]) + ");");
  +		    writer.println("_jspx_qfStr = _jspx_qfStr + \"" + sep +
  +				   key + "=\" + " + JspUtil.getExpr(value[0]) + ";");
   		else {
   		    if (value.length == 1)
  -			writer.println("request.setAttribute(\"" + key + "\", \"" + value[0] + "\");");
  +			writer.println("_jspx_qfStr = _jspx_qfStr + \"" + sep +
  +				       key + "=\" + \"" + value[0] + "\";");			
   		    else {
  -			writer.println("{");
  -			writer.pushIndent();
  -			writer.println("String [] _tmpS = new String[" + value.length +"];");
  -			for (int i = 0; i < value.length; i++)
  +			for (int i = 0; i < value.length; i++) {
   			    if (!JspUtil.isExpression(value[i]))
  -				writer.println("_tmpS[" +  i + "] = \"" + value[i] + "\";");
  +				writer.println("_jspx_qfStr = _jspx_qfStr + \"" + sep +
  +					       key + "=\" + \"" + value[i] + "\";");
   			    else
  -				writer.println("_tmpS[" +  i + "] = " +
  -					       JspUtil.getExpr(value[i]) + ";");	
  -			writer.println("request.setAttribute(\"" + key + "\", _tmpS);");
  -			writer.popIndent();
  -			writer.println("}");
  +				writer.println("_jspx_qfStr = _jspx_qfStr + \"" + sep +
  +					       key + "=\" +" + JspUtil.getExpr(value[i])+ ";");
  +			    if (sep.equals("?")) sep = "&";			    
  +			}
   		    }
   		}
   	    }
   	}
   	if (!isExpression)
               writer.println("pageContext.forward(" +
  -			   writer.quoteString(page) +
  -			   ");");
  +			   writer.quoteString(page) + " +  _jspx_qfStr);");
   	else
               writer.println("pageContext.forward(" +
  -			   JspUtil.getExpr (page) +
  -			   ");");
  +			   JspUtil.getExpr (page) +  " +  _jspx_qfStr);");
  +	
           writer.println("return;");
           writer.popIndent();
           writer.println("}");
  
  
  
  1.3       +34 -33    jakarta-tomcat/src/share/org/apache/jasper/compiler/IncludeGenerator.java
  
  Index: IncludeGenerator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/IncludeGenerator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IncludeGenerator.java	1999/10/17 18:40:06	1.2
  +++ IncludeGenerator.java	1999/10/19 21:34:50	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/IncludeGenerator.java,v
1.2 1999/10/17 18:40:06 mandar Exp $
  - * $Revision: 1.2 $
  - * $Date: 1999/10/17 18:40:06 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/IncludeGenerator.java,v
1.3 1999/10/19 21:34:50 mandar Exp $
  + * $Revision: 1.3 $
  + * $Date: 1999/10/19 21:34:50 $
    *
    * ====================================================================
    * 
  @@ -110,53 +110,54 @@
       }
       
       public void generate(ServletWriter writer, Class phase) {
  +	boolean initial = true;
  +	String sep = "?";
  +	writer.println("{");
  +	writer.pushIndent();
  +	writer.println("String _jspx_qStr = \"\";");
           writer.println("out.flush();");
  +	
   	if (params.size() > 0) {
   	    Enumeration en = params.keys();
   	    while (en.hasMoreElements()) {
   		String key = (String) en.nextElement();
   		String []value = (String []) params.get(key);
  +		if (initial == true) {
  +		    sep = "?";
  +		    initial = false;
  +		} else sep = "&";
   		
  -		if (value.length == 1 && JspUtil.isExpression(value[0]))
  -		    writer.println("request.setAttribute(\"" + key + "\", " +
  -				   JspUtil.getExpr(value[0]) + ");");
  -		else {
  -		    if (value.length == 1)
  -			writer.println("request.setAttribute(\"" + key + "\", \"" + value[0] + "\");");
  -		    else {
  -			writer.println("{");
  -			writer.pushIndent();
  +		if (value.length == 1 && JspUtil.isExpression(value[0])) {
  +		    writer.println("_jspx_qStr = _jspx_qStr + \"" + sep +
  +				   key + "=\" + " + JspUtil.getExpr(value[0]) + ";");
  +		} else {
  +		    if (value.length == 1) {
  +			writer.println("_jspx_qStr = _jspx_qStr + \"" + sep +
  +				       key + "=\" + \"" + value[0] + "\";");
  +		    } else {
   			writer.println("String [] _tmpS = new String[" + value.length +"];");
  -			for (int i = 0; i < value.length; i++)
  +			for (int i = 0; i < value.length; i++) {
   			    if (!JspUtil.isExpression(value[i]))
  -				writer.println("_tmpS[" +  i + "] = \"" + value[i] + "\";");
  +				writer.println("_jspx_qStr = _jspx_qStr + \"" + sep +
  +					       key + "=\" + \"" + value[i] + "\";");
   			    else
  -				writer.println("_tmpS[" +  i + "] = " +
  -					       JspUtil.getExpr(value[i]) + ";");	
  -			writer.println("request.setAttribute(\"" + key + "\", _tmpS);");
  -			writer.popIndent();
  -			writer.println("}");
  +				writer.println("_jspx_qStr = _jspx_qStr + \"" + sep +
  +					       key + "=\" +" + JspUtil.getExpr(value[i])+ ";");
  +			    if (sep.equals("?")) sep = "&";
  +			    
  +			}
   		    }
   		}
   	    }
   	}
   	if (!isExpression) 
   	    writer.println("pageContext.include(" +
  -			   writer.quoteString(page) +
  -			   ");");
  +			   writer.quoteString(page) + " + _jspx_qStr);");
   	else
  -	    writer.println ("pageContext.include(" +
  -			    JspUtil.getExpr(page) +
  -			    ");");
  +	    writer.println ("pageContext.include(" + 
  +			    JspUtil.getExpr(page) + " + _jspx_qStr);");
   
  -	// Now remove the parameters that were meant only for the inclusion.
  -	if (params.size() > 0) {
  -	    Enumeration en = params.keys();
  -	    while (en.hasMoreElements()) {
  -		String key = (String) en.nextElement();
  -		writer.println("request.removeAttribute(\"" + key + "\");");
  -	    }
  -	}
  -	
  +	writer.popIndent();
  +	writer.println("}");
       }
   }
  
  
  

Mime
View raw message