Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
-none-

-none-

2007-10-01       - By Daniel M Garland

 Back
Any thoughts? If this is OT anyone know an appropriate list to post to?

Daniel M Garland wrote:
> Hi all,
>
> I have a web application that is installed on a virtual host that has a
> number of subdomains defined with <Alias> elements in server.xml. We
> would like cookie sessions persist to across these subdomains, and I
> understand that this is not standard as defined in the servlet
> specification. Therefore I am trying to write a custom Valve that
> re-writes the domain on a Cookie to be ".mydomain.com", rather than
> "www.mydomain.com". From searching the web to looking at what Daniel
> Rall wrote for Tomcat 4 I have tried the invoke() method below in my
> valve. Unfortunately, it doesn't seem to work; in my log I see the debug
> output that tells me the domain is being set, but when I look at the
> cookie in my Firefox web developer toolbar it says that the host of the
> cookie is www.mydomain.com.
>
> Has anyone got this to work in Tomcat 5.5.2? Why doesn't this code work
> and can anybody tell me if there is anything else I need to change? From
> what I can tell if this doesn't work my options are to edit Tomcat
> sources or persuade the boss to get Resin (which supports this feature).
>
> BTW I already have cookies="false" in my Context for the time being, its
> OK as an interim measure but I'd prefer to have cookies sorted.
>
> public void invoke(Request request, Response response) throws
> IOException, ServletException
>    {
>       if(request instanceof HttpServletRequest &&
>          response instanceof HttpServletResponse &&
>          request.getCookies() != null)
>       {
>         HttpServletRequest httprequest = (HttpServletRequest) request;
>         HttpServletResponse httpresponse = (HttpServletResponse) response;
>
>         boolean domainwasset = setDomainOnCookies(request.getCookies());
>         if(!domainwasset)
>         {
>            HttpSession session = httprequest.getSession();
>            if(session.isNew())
>            {
>                containerLog.info((session.isNew() ? "new" : "old") + "
> session, requested ID="
>                      + httprequest.getRequestedSessionId() + ", actual
> ID =" + session.getId());
>
>
>            Cookie cookie = new Cookie(Globals.SESSION_COOKIE_NAME,
> session.getId());
>            cookie.setMaxAge(-1);
>
>            // Set the cookie path
>            String cookiepath = getCookiePath();
>            if(cookiepath == null || cookiepath.trim().length() == 0)
>            {
>                cookiepath = request.getContextPath();
>                if(cookiepath == null || cookiepath.trim().length() == 0)
>                {
>                   cookiepath = "/";
>                }
>            }
>
>            if(httprequest.isSecure())
>            {
>              cookie.setSecure(true);
>            }
>
>            cookie.setDomain(getCookieDomain());
>            containerLog.info("Adding cookie for "+ getCookieDomain());
>            httpresponse.addCookie(cookie);
>            }
>         }
>
>       }
>
>       // We're done, bring on the next valve
>       if(next != null)
>       {
>          next.invoke(request, response);
>       }
>    }
>
>    private boolean setDomainOnCookies(Cookie[] cookies)
>    {
>       boolean domainset = false;
>       if(cookies != null)
>       {
>          for(Cookie c : cookies)
>          {
>             if(c != null &&
> c.getName().equals(Globals.SESSION_COOKIE_NAME))
>             {
>                containerLog.info("Setting cookie " + c.getName() +" to "
> + getCookieDomain() + ", was " + c.getDomain());
>                c.setDomain(getCookieDomain());
>                domainset = true;
>             }
>          }
>       }
>
>       return domainset;
>    }
>
>
> Thanks in advance
> Dan Garland
> daniel.garland@(protected)
>
> __ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> __ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __
>
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
> To start a new topic, e-mail: users@(protected)
> To unsubscribe, e-mail: users-unsubscribe@(protected)
> For additional commands, e-mail: users-help@(protected)
>
>
> __ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> __ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __
>

__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)


©2008 junlu.com - Jax Systems, LLC, U.S.A.