cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sonney <ke...@webslingerz.com>
Subject Re: More cookies
Date Thu, 27 Jul 2000 18:10:30 GMT
On Thu, 27 Jul 2000, Donald Ball wrote:
> <xsp:logic>
>  response.addCookie(new Cookie("cookie","Test Value"));
> </xsp:logic>

That's what's in the generated Java :
      response.addCookie(
        
      new Cookie(
        String.valueOf("test"),
        String.valueOf("Test Value")
      )


> what the relevant snippet of code from your generated XSP page look
> like?

See above. Identical, except for the valueOf calls. I know the cookies are
being set, because I'm getting the fun little netscape pop-ups.

The more I work with the cookie xsp and look over the generated code, the
more I see the need to rewrite it, as it's for some flaws in it. You were
correct in your assessment earlier that it's doing something bad with the
cookie.* calls. I just attempted the following XML :


<cookie:create name="test">
	<value>TestCookie</value>
	<cookie:set-comment>
		<purpose>Test Cookie</purpose>
	</cookie:set-comment>
</cookie:create>
<response:add-cookie>
</response:add-cookie>
<cookie:set-max-age>
	<expiry>172800</expiry>
</cookie:set-max-age>
<cookie:set-domain> 
	<pattern>.webslingerZ.com</pattern>
</cookie:set-domain>
<cookie:set-path path="/~kevin/" />
<cookie:set-secure flag="true" />
<cookie:set-version value="1.0" />

And got what I can only call bad Java code out of it - here's what the
compiler says :

Error found handling the request.
java.lang.Exception: XSP Java Compiler: Compilation failed for _index.java
       119: Incompatible type for method. Can't convert java.lang.String to javax.servlet.http.Cookie.
 ""
 ^
123: Undefined variable or class name: cookie
   cookie.setMaxAge(
   ^
131: Undefined variable or class name: cookie
   cookie.setDomain(
   ^
137: Undefined variable or class name: cookie
   cookie.setPath(
   ^
143: Undefined variable or class name: cookie
   cookie.setSecure(
   ^
151: Undefined variable or class name: cookie
   cookie.setVersion(
   ^
6 errors

And the .java file :

        xspCurrentNode.appendChild(
          xspExpr(
      new Cookie(
        String.valueOf("WB-User"),
        String.valueOf("ksonney")
      )
    , document)
        );
      
      response.addCookie(
        ""
        
      );
    
      cookie.setMaxAge(
        Integer.ParseInt(
          String.valueOf(
            "172800"
          )
        )
      );
    
      cookie.setDomain(
        String.valueOf(
          ".unc.edu"
        )
      );
    
      cookie.setPath(
        String.valueOf(
          "/webboard/wbpx.dll/~casboard/"
        )
      );
    
      cookie.setSecure(
        new Boolean(
          String.valueOf(
            "true"
          )
        ).booleanValue()
      );
    
      cookie.setVersion(
        Integer.ParseInt(
          String.valueOf(
            "1.0"
          )
        )
      );
 

Ewwwww. Well, that's not gonna work, now is it? I figure the proper way to
do it is this :

<cookie:create name="Name" comment="Comment" />

Should do this :

Name = new Cookie("Name","Comment");

All further cookie: tags would *THEN* require a "name" attribute so we can
properly modify all the properties of said cookie :

<cookie:set-max-age name="Name" expiry="178200" />
becomes
Name.setMaxAge(178200);

FInally, we shuold be able to pass the object name to response:add-cookie
like so :

<response:add-cookie>Name</response:add-cookie>

should (IMHO) result in 

response.addCookie(Name);

Does all this make sense, and is anyone willing to work with me on these
changes? Or did I just volunteer my lonely self to make them?

-- 
- Kevin Sonney
  kevin@webslingerZ.com


Mime
View raw message