Re: OAS Jservlets and READING cookies

From: Johan Viberg <viberg_at_my-deja.com>
Date: Tue, 28 Mar 2000 09:45:20 GMT
Message-ID: <8bpuve$de4$1_at_nnrp1.deja.com>


I have the exact same, annoying, problem! I've found two solutions (workarounds):

  1. If you do 'req.getSession(true);' OAS will set its own session specific cookies and then, as by magic, in the next http-request, you will also be able to read the cookie you set yourself! The thing is you might not want to start a new session(I don't)
  2. You can directly access the http-header through 'req.getHeader("cookie");'. This will give you all of your cookies as a long String, which you'll have to parse in order to find your cookie. This is a better solution.

Regards
Johan

In article <8b4ncq$u6c$1_at_nnrp1.deja.com>, Hyper B Orean <hyper.b.orean_at_autonomous.org> wrote:
> It seems I am having some little problem with Jservlets under OAS
> 4.0.8.1 ... I just ported a whole heap of ex-JWEB cartridges to
> Jservlets for a bit of 'futureproofing'.
> After having to tell Oracle Support how one uses the oracle.html
> package AND set cookies with the standard java servlet J2EE methods,
it
> appears that I cannot READ cookies with the standard methods; i.e.
> public void doGet(HttpServletRequest req, HttpServletResponse resp)
> throws ServletException, IOException {
> try {
> Cookie theCookies[] = req.getCookies();
> for (int i=0; i < theCookies.length; i++) {
> // some code here to get each Cookie
> }
> } catch (NullPointerException e) {
> // error handling code
> }
> basically the code above ALWAYS throws NullPointerException because
the
> array 'theCookies[]' is always NULL ... i.e. req.getCookies() returns
> nothing even though the J2EE information I have here says its meant to
> return an array of Cookie objects. I know there's cookies because I
can
> read them in with a LiveHTML cartridge. Is there something I am not
> doing?? Or is this yet another stupid OAS bug or omission?
> Am I just forced to read in all the headers off the request object in
> their raw form, check for the 'Cookie' headers and then parse them
> myself?? I'd prefer not to if I have to. And I haven't verified that
> the getHeaders() method works either!!!
> I can read the QueryString, and various specialised headers with their
> specific get() methods, all OK.
> Has anyone been able to read cookies with JServlets under OAS
4.0.8.1??
> This error occurs to me on both Linux and NT versions.
> regs
> h.b.o.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Tue Mar 28 2000 - 11:45:20 CEST

Original text of this message