You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by fe...@apache.org on 2004/11/18 01:28:54 UTC

cvs commit: jakarta-taglibs-sandbox/image/xml image.xml

felipeal    2004/11/17 16:28:53

  Modified:    image/src/org/apache/taglibs/image ImageServlet.java
                        ImageTag.java
               image/xml image.xml
  Log:
  fix for 32272: added usingImageNameInSession parameter (Thanks Daniel Amadei for the patch)
  
  Revision  Changes    Path
  1.2       +12 -2     jakarta-taglibs-sandbox/image/src/org/apache/taglibs/image/ImageServlet.java
  
  Index: ImageServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/image/src/org/apache/taglibs/image/ImageServlet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ImageServlet.java	10 Jun 2004 13:58:21 -0000	1.1
  +++ ImageServlet.java	18 Nov 2004 00:28:53 -0000	1.2
  @@ -14,6 +14,7 @@
   
   import javax.servlet.ServletException;
   import javax.servlet.http.HttpServlet;
  +import javax.servlet.http.HttpSession;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
   
  @@ -33,8 +34,17 @@
                           "Image temp directory " + imageDir + " not found");
                   return;
           }
  -        
  -        String imageName = req.getParameter("image");
  +
  +				//maybe using getSession(false) would fit better
  +				HttpSession session = req.getSession();
  +
  +				String useSession = req.getParameter("useSession");
  +
  +				String imageName = req.getParameter("image");
  +
  +        if(useSession != null && useSession.equalsIgnoreCase("true")) {
  +        	imageName = (String)session.getAttribute("org.apache.taglibs.image.ImageName");
  +        }
   
           File image = new File(imageDir, imageName);
           if (image == null || !image.exists() || !image.isFile()) {
  
  
  
  1.9       +25 -5     jakarta-taglibs-sandbox/image/src/org/apache/taglibs/image/ImageTag.java
  
  Index: ImageTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/image/src/org/apache/taglibs/image/ImageTag.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ImageTag.java	10 Jun 2004 13:58:21 -0000	1.8
  +++ ImageTag.java	18 Nov 2004 00:28:53 -0000	1.9
  @@ -63,7 +63,9 @@
       private static final String CONTEXT_TEMPDIR = "javax.servlet.context.tempdir";
   
       public static final String IMAGE_SERVLET_MAPPING = "ImageServletMapping";
  -
  +    
  +    private static final String SESSION_ATTR_IMAGE_NAME = "org.apache.taglibs.image.ImageName";
  +    
       protected String src;
   
       protected String attributes;
  @@ -101,14 +103,20 @@
       protected boolean usingContextTempDir;
   
       protected String servletMapping;
  -    
  +
       protected String servletMappingContextParameter = IMAGE_SERVLET_MAPPING;
   
  +    protected boolean usingImageNameInSession;
  +
       public int doStartTag() throws JspException {
           initialize();
           doChecks();
   
           try {
  +        		if(usingImageNameInSession) {
  +        			pageContext.getSession().setAttribute(SESSION_ATTR_IMAGE_NAME, name);
  +        		}
  +
               getLocalImageFile();
               createImaging();
               fetchImage();
  @@ -291,13 +299,18 @@
           } else {
               attributes = ""; //a work around for the following conditions.
           }
  +
           //checking if the user has already specified the attributes.
           String al = attributes.toLowerCase();
           if (al.indexOf(" src") == -1) {
               if (usingContextTempDir) {
  -                html.append(" src=" + '"' + hreq.getContextPath()
  -                        + getServletUrlString() + "?image=" + img.getName()
  -                        + '"');
  +                if(usingImageNameInSession) {
  +	                html.append(" src=" + '"' + hreq.getContextPath()
  +	                        + getServletUrlString() + "?useSession=true" + '"');
  +                } else {
  +	                html.append(" src=" + '"' + hreq.getContextPath() 
  +	                				+ getServletUrlString() + "?image=" + img.getName() + '"');
  +                }
               } else {
                   html.append(" src=" + '"' + hreq.getContextPath() + '/' + dir
                           + '/' + img.getName() + '"');
  @@ -444,6 +457,13 @@
   
       public void setQuality(float quality) {
           this.quality = quality;
  +    }
  +
  +    public void setUsingImageNameInSession(boolean b) {
  +    		this.usingImageNameInSession = b;
  +    }
   
  +    public boolean isUsingImageNameInSession() {
  +    		return this.usingImageNameInSession;
       }
   }
  
  
  
  1.8       +15 -0     jakarta-taglibs-sandbox/image/xml/image.xml
  
  Index: image.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/image/xml/image.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- image.xml	10 Jun 2004 13:58:21 -0000	1.7
  +++ image.xml	18 Nov 2004 00:28:53 -0000	1.8
  @@ -297,6 +297,18 @@
           	</description>
           	<availability>1.0</availability>            
           </attribute>
  +
  +        <attribute>
  +            <name>usingImageNameInSession</name>
  +            <required>false</required>
  +            <rtexprvalue>false</rtexprvalue>
  +            <type>boolean</type>
  +        	<description>
  +						Indicates that the servlet uses the name of the image stored in the session.
  +        	</description>
  +        	<availability>1.0</availability>            
  +        </attribute>
  +
           <attribute>
               <name>dir</name>
               <required>false</required>
  @@ -1094,6 +1106,9 @@
       More changes based on user feedback.
     </description>
     <section name="New Features">
  +    <item>
  +      New usingImageNameInSession parameter (see bug 32272)
  +    </item>
       <item>
         New Tag to add transparency to an image.
       </item>
  
  
  

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