[jboss-user] [JBoss Portal] - ETag

Umesh Pathak do-not-reply at jboss.com
Fri Feb 4 05:06:35 EST 2011


Umesh Pathak [http://community.jboss.org/people/smart_umesh_123] created the discussion

"ETag"

To view the discussion, visit: http://community.jboss.org/message/585438#585438

--------------------------------------------------------------
I tried the response.getCacheControl().setUseCachedContent(true). but it does not work.



Here is my portlet class

- 
package com.mycompany.frs.portlet; 
public class CacheDemo extends GenericPortlet 
{  
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException 
{ 
System.out.println("**---- " + this.getClass().getName() + "'s doView is started"); 

if (request.getETag() != null) 
{ 
if (request.getETag().startsWith("MY_ETAG")) 
{ 
System.out.println("/////// MARKUP IS VALID"); 
response.getCacheControl().setExpirationTime(30); 
response.getCacheControl().setUseCachedContent(true); 
return; 
} 
} 
else 
{ 
response.getCacheControl().setETag("MY_ETAG" + (new Date())); 
response.getCacheControl().setExpirationTime(30); 
PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/CacheDemo.jsp"); 
dispatcher.include(request, response); 
} 

}  
} 


*portlet.xml =*

<portlet> 
        <description>CacheDemo</description>
        <portlet-name>CacheDemo</portlet-name>
         <display-name>CacheDemo</display-name>
         <portlet-class>com.mycompany.frs.portlet.CacheDemo</portlet-class>       
         <supports>
             <mime-type>text/html</mime-type>
             <portlet-mode>VIEW</portlet-mode>
         </supports>
         <supports>
             <mime-type>text/html</mime-type>
             <portlet-mode>EDIT</portlet-mode>
         </supports>
         <supports>
             <mime-type>text/html</mime-type>
             <portlet-mode>HELP</portlet-mode>
         </supports>
         <portlet-info>
             <title>CacheDemo</title>
             <short-title>CacheDemo</short-title>
         </portlet-info>
         <expiration-cache>30</expiration-cache>           
     </portlet>

*CacheDemo.jsp*


<%@page import="java.util.Date"%>
 <H1> Hello Friends, I am cached contents !! </H1>
 <%= new Date() %>

*Platform* : Jboss Portal 2.7.2 

 *Problem :*

When I refresh the page after 30 seconds, the portlet vanishes from the Portal page.
 When I again refresh the page immediately, the portlet appears, with the cached contents. That is, it does not show the current date
-----------------
Thanks

Umesh Pathak
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/585438#585438]

Start a new discussion in JBoss Portal at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2011]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110204/0368ebe5/attachment.html 


More information about the jboss-user mailing list