DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20594>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20594

Velocity Template with HTTPRequest object

           Summary: Velocity Template with HTTPRequest object
           Product: Velocity
           Version: 1.3
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Build
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]
                CC: [EMAIL PROTECTED]


Hi,

I am having a problem with velocity.
I am using:
1. Tomcat version 4.1.18 
2. velocity-dep-1.3.jar 
3. Java1.4.0( build 1.4.0-b92) 
4. Windows 2000.

I am using velocity template with servlets.

Problem Description:
1.Whenever one of the parameters for  a method is HTTPRequest object in the 
velocity template the 

link does not get translated.
2.If the method has only HTTPRequest object as the parameter it works.
3.But HTTPRequest in combination with other parameters does not seem to work.

For Example:
Following DO NOT WORK:
<h2> <a href="$link.getBrowseURL($request, "A", 1, 15)">REQ + String + Int = 
NOT WORKING</a></h2>
<h2> <a href="$link.getBrowseURL( "A", 1, 15,$request)">String + Int + REQ = 
NOT WORKING</a></h2>
<h2> <a href="$link.getBrowseURL( $request,1, 15)">REQ + Integer = NOT 
WORKING</a> </h2>

Following WORK:
<h2> <a href="$link.getBrowseURL("A", 1, 15)">String + Int = Working</a> </h2>
<h2> <a href="$link.getBrowseURL( 1, 15)">Only Integer = WORKING </a> </h2>
<h2> <a href="$link.getBrowseURL( $request)">Only REQ = WORKING</a> </h2>


IS this a BUG or mistake on my part.ANY suggestions are welcome.


THANK YOU
Sushma
Following is the code for velocity and servlet.
+++++++++++++++++++++++++++++homepage3.vm+++++++++++++++++++++++++++++++++++++++
<html>

<body>

<h2> <a href="$link.getBrowseURL($request, "A", 1, 15)"> REQ + String + Int = 
NOT WORKING</a></h2>
<h2> <a href="$link.getBrowseURL( "A", 1, 15,$request)">String + Int + REQ = 
NOT WORKING</a></h2>
<h2> <a href="$link.getBrowseURL( $request,1, 15)">REQ + Integer = NOT 
WORKING</a> </h2>
<h2> <a href="$link.getBrowseURL("A", 1, 15)">String + Int = Working</a> </h2>
<h2> <a href="$link.getBrowseURL( 1, 15)">Only Integer = WORKING </a> </h2>
<h2> <a href="$link.getBrowseURL( $request)">Only REQ = WORKING</a> </h2>

</body>

</html>
-----------------------------homepage3.vm---------------------------------------

+++++++++++++++++++++++++++++WorkingServlet.java++++++++++++++++++++++++++++++++
import java.text.*;
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

import org.apache.velocity.*; 
import org.apache.velocity.app.Velocity; 
import org.apache.velocity.context.Context; 
import org.apache.velocity.runtime.RuntimeSingleton;
import org.apache.velocity.util.SimplePool;
import org.apache.velocity.exception.*;


public class WorkingServlet extends HttpServlet {
   String encoding;
   private  SimplePool writerPool = new SimplePool(40);
   
   public void init() throws UnavailableException { 
        String prefix =  getServletContext().getRealPath("/");
        String file = getInitParameter("velocity-init-file");

                if(file != null) {
            try {
                        String propertiesFile = prefix+file;
                        String filePath= prefix;
            Properties p = new Properties();
            p.load(new FileInputStream(propertiesFile));

            p.setProperty( Velocity.FILE_RESOURCE_LOADER_PATH,  filePath );

            Velocity.init(p);             
            encoding = RuntimeSingleton.getString( 
RuntimeSingleton.OUTPUT_ENCODING, 
                                                   "ISO-8859-1");
            } catch (Exception e) {
                throw new UnavailableException(e.getMessage());
            } //end of catch
            
        }//end of if
    }//end of init
    
        public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException
    {  
                response.setContentType("text/html");
                PrintWriter out = response.getWriter();
                try{
           VelocityContext context = new VelocityContext(); 

       context.put("link", new WorkingServlet()); 
           context.put("request", request); 

           Template tpl = RuntimeSingleton.getTemplate("homepage3.vm");
       tpl.merge( context,out);
           }catch (Exception e){
                }//end of catch
    }//end of doGet
        
   public String getBrowseURL(HttpServletRequest request,String startStr,int 
startPt, int fetchCount) 
   {
           return("HEllO REQUEST");
   }

   public String getBrowseURL(String startStr,int startPt, int 
fetchCount,HttpServletRequest request) 
   {
           return("HEllO REQUEST");
   }
   public String getBrowseURL(HttpServletRequest request, int startPt, int 
fetchCount) 
   {
           return("HEllO REQUEST");
   }

   public String getBrowseURL(String startStr,int startPt, int fetchCount) 
   {
           return("HEllO REQUEST");
   }

   public String getBrowseURL(int startPt, int fetchCount) 
   {
           return("HEllO REQUEST");
   }
   public String getBrowseURL(HttpServletRequest request) 
   {
           return("HEllO REQUEST");
   }


}//end of class

-----------------------------WorkingServlet.java--------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to