Re[2]: Barracuda: Updated HttpRequester
Jacob Kjome <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Organization | Springfield Nuclear Plant |
| Message-ID | <[email protected]> |
Hello Shawn,
That would make more sense. You might want to check if there are any
differences between the servlet-2.2 and servlet-2.3 api for the Cookie
class. Hopefully they are the same. If not, make sure to document
what is servlet-2.3 specific. And, yes, you could go ahead extend
Cookie. However, I still would like to know what functionality you
are looking to get out of your custom Cookie class that the servlet api doesn't provide?
Like I said, a simple getCookie() is the only thing I see lacking and
that isn't even really a problem with the Cookie class, it is a
problem with the HttpServletRequest class....
public static Cookie getCookie(HttpServletRequest req, String cookieName) {
Cookie cookie = null;
Cookie[] cookies = req.getCookies();
if (cookies!=null) {
for (int i=0; i < cookies.length; i++) {
if (cookies[i].getName().equals(cookieName)) {
cookie = cookies[i];
break;
}
}
}
return cookie;
}
I would think this could be put in something like
RequestServices.java which would be analogous to classes like
SessionServices or ContextServices in
org.enhydra.barracuda.plankton.http.
I think it confuses the issue to extend the Cookie
class if you aren't going to override existing behavior. We should
make use of the servlet api directly as much as possible, otherwise we
have some extra maintenance on our hands.
What do you think?
Jake
Wednesday, November 27, 2002, 2:10:27 PM, you wrote:
SW> Jake,
SW> You have a good point. When I looked for an existing basic Cookie class,
SW> I looked through the J2SE 1.4 API docs but I didn't think to look
SW> through the J2EE API (where the servlet packages are).
SW> Looking at javax.servlet.http.Cookie now, I probably could have just
SW> extended that class to add a few additional constructors and methods I
SW> provide in mine. If you think it is worth it, I can go ahead and make
SW> this change and post the updated code.
SW> Thanks,
SW> -shawn
SW> Jacob Kjome wrote:
>> Hello Shawn,
>>
>> I haven't looked at this much, but doesn't the Cookie class duplicate
>> the functionality of the servlet api's Cookie class?
>>
>> The only real thing lacking with the servlet api's Cookie class is
>> that it doesn't have a getCookie("mycookie") method. You have to get
>> all cookies and loop through them. A utility method for this would be
>> fine, but why the duplication of the whole Cookie class?
>>
>> Jake
>>
>> Wednesday, November 27, 2002, 12:49:32 PM, you wrote:
>>
>> SW> Folks,
>>
>> SW> I have made some updates to the
>> SW> org.enhydra.barracuda.plankton.http.HttpRequester class to support the
>> SW> use of cookies between server and client. This also involved the
>> SW> creation of a new org.enhydra.barracuda.plankton.http.Cookie class to
>> SW> represent an HTTP cookie.
>>
>> SW> I have attached these files to this email, so if someone thinks this
>> SW> update may be useful they can use it themselves or a committer can
>> SW> commit it to the barracuda tree or whatever you guys feel you want to do
>> SW> with it.
>>
>> SW> Thanks!
>> SW> -shawn
>>
>>
>>
>>
--
Best regards,
Jacob mailto:[email protected]
_______________________________________________
Barracuda mailing list
[email protected]
http://www.enhydra.org/mailman/listinfo.cgi/barracuda
FAQ - http://www.jguru.com/faq/Barracuda