cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kumar, Kiran" <kku...@kheaa.com>
Subject RE: Problem with sharing sessions/ multithreading
Date Sun, 17 Apr 2005 16:57:27 GMT
looks like the Filter works but not all the time..

	private FilterConfig filterConfig;
	//Handle the passed-in FilterConfig
	public void init(FilterConfig filterConfig) {
		this.filterConfig = filterConfig;
	}
	//Process the request/response pair
	public void doFilter(
		ServletRequest request,
		ServletResponse response,
		FilterChain filterChain) {
		try {
			request.setCharacterEncoding("GB2312");
			((HttpServletResponse)
response).setHeader("Cache-control","no-cache");
			((HttpServletResponse) response).setHeader("Pragma",
"No-cache");
			((HttpServletResponse)
response).setHeader("Expires", "0");
			filterChain.doFilter(request, response);
		} catch (ServletException sx) {
	
filterConfig.getServletContext().log(sx.getMessage());
		} catch (IOException iox) {
	
filterConfig.getServletContext().log(iox.getMessage());
		}
	}
	//Clean up resources
	public void destroy() {
	

Is there any thing else I need to do to make this filter not Cache all time.


In test,  till now I was logging as the same user in 2 systems , logout,
access account,  hit back button and login again.
             It displays the correct information. 

now I switched users after logout.. and it displays correct information. But
the problem is when I hit refresh, it displayed the information of the 
previous user..  

any clues on this           




thanks

Kiran Kumar (Raj)
 
(502) 696-7203




-----Original Message-----
From: Kumar, Kiran 
Sent: Sunday, April 17, 2005 12:47 PM
To: 'dev@cocoon.apache.org'
Subject: RE: Problem with sharing sessions/ multithreading


also in the following pipeline, how can I display a html page after the
homepage action is called?

    <map:handle-errors>
	      <map:select type="exception">
			<map:when test="processing">
				  <map:act type="home-page">
						--------------------right
here I need to call a HTML page	
				  </map:act>
			</map:when>
	      </map:select>
	    </map:handle-errors>

thanks

Kiran Kumar (Raj)
 
(502) 696-7203




-----Original Message-----
From: Ralph Goers [mailto:Ralph.Goers@dslextreme.com]
Sent: Sunday, April 17, 2005 12:27 PM
To: dev@cocoon.apache.org
Subject: Re: Problem with sharing sessions/ multithreading


Torsten Curdt wrote:

>
>Don't want to be picky ...but better don't use DCL
>
>http://www.javaworld.com/javaworld/jw-05-2001/jw-0525-double.html
>
>cheers
>  
>
Thanks, that article wasn't too helpful in figuring out why the 
technique doesn't work. However, it refreences an article from Alan 
Holub that does. From his description, the following version of the DCL 
should work fine.  I'm not sure the function actually has to be static. 
 From what I could tell synchronized should be sufficient.

Document getDocument()
{
        Request request = ObjectModelHelper.getRequest(objectModel);
        Session session = request.getSession(true);
        Document doc = (Document)session.getAttribute("myAttribute");
        if   (doc == null)
        {
             // It is possible for more than one thread to get here at 
the same time with doc == null
             syncronize(LOCK);
             {     // So check again. Only the first caller should 
actually create the document.
                   doc = (Document)session.getAttribute("myAttribute");
                   if (doc == null)
                   {     
                        DocumentBuilderFactory dbf  = 
DocumentBuilderFactory.newInstance();                             
                     
                        doc = buildDocument(dbf);
                        session.setAttribute("myAttribute", doc);
                    }                        
             }
        }
        return doc;
}

private static synchronized Document 
buildDocument(DocumentBuilderFactory dbf)
{
    return dbf.newDocumentBuilder().newDocument();
}

>--
>Torsten
>  
>

Mime
View raw message