cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Newland" <chris.newl...@emorphia.com>
Subject RE: Cocoon2 Cookie Recipe?
Date Fri, 07 Dec 2001 11:17:56 GMT
Hi Liam,

Yes you can write an action to set a cookie and have the sitemap determine
when to call the action.

I use an action that sets a cookie according to request parameters.

This code should do the trick, just fill in the blanks:

---------------------------------------------------
import java.util.Map;
import java.util.HashMap;
import java.util.Enumeration;

import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.Constants;
import org.apache.cocoon.acting.AbstractAction;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.Session;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.SourceResolver;

import org.apache.cocoon.components.language.markup.xsp.XSPCookieHelper;

public class StoreCookieAction extends AbstractAction
{

	public Map act(Redirector redirector, SourceResolver resolver, Map
objectModel, String src, Parameters par)
		throws Exception
	{

		Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);

		String remember_user = request.getParameter("remember");

		if (remember_user != null && remember_user.equals("on"))
		{

			String value = ;

			String name = ;

			String comment = ;

			String domain = ;

			int maxage = ;

			String path = ;

			String secure = ;

			int version = ;

			XSPCookieHelper.addCookie(objectModel, name, value, comment, domain,
maxage, path, secure, version);

		}

		return new HashMap();
	}
}
------------------------------------------------


Hope this helps,

Best Regards,

Chris

-----Original Message-----
From: Liam Morley [mailto:lmorley@WPI.EDU]
Sent: 06 December 2001 23:45
To: cocoon-users@xml.apache.org
Subject: RE: Cocoon2 Cookie Recipe?


And if you're not using XSP, what then? Is it possible to set cookies
within the sitemap/XSL, using a Java Cocoon action?

Liam Morley


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>



---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message