Well, Milt, I will certainly defer to you in Java expertise. Thing is, I
was just wrestling with a problem very close to this yesterday and there is
(a) a definite difference between a string (literal) and a String (object)
when it comes to some of the API methods. (b) Equals() is a strange beast
in any event and, IMHO should be more clearly defined at the Object level
(or at least give us an interface for it). "Application" in the JSP spec
seems to me the equivalent of "session" in the Servlet spec, though in the
JSP spec "session" is not much more than a page context. (c) We know that
equals() will accept a literal, but the J2EE API states specifically that
"getAttribute" takes a string as its first parameter and an object as its
second. Hence, you access the attribute by its literal name, which brings
the object into scope and then you need cast the object to its type before
accessing its properties.
Cheers!
Mark
This email scanned with Norton AntiVirus 2002
----- Original Message -----
From: "Milt Epstein" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 18, 2001 6:55 PM
Subject: Re: Communication between JSP and servlets
> On Tue, 18 Dec 2001, Mark Galbreath wrote:
>
> > Look at the API - setAttribute() takes a String and an Object, not 2
> > Strings. Try something like:
> >
> > String errorMessage = "NO Error Message";
> > application.setAttribute( "errorMessage", errorMessage);
>
> Mark, I think you're losing it :-).
>
> Surely a double quoted string literal is a String object (or is
> translated/converted to a String object -- I'm not surely exactly how
> the language spec technically deals with it.) How else could you do
> things like:
>
> "a".equals("b")
>
> And of course, if that was the problem, the code below wouldn't even
> compile.
>
> Not that I do know what the problem is :-).
>
> But here's a quesiton: application is a pre-defined identifier in
> JSPs, but what is the application in the line of servlet code below?
>
>
> > -----Original Message-----
> > From: Jim Lindsay
> > Sent: Tuesday, December 18, 2001 2:49 PM
> >
> > I am not able to get session or application scope tracking to work for
some
> > reason. Currently the code is trying to use
> > application tracking, but I know I should be using session tracking for
> > items that are for the user session.
> >
> > In my userLoggidIn.jsp page I have:
> > Error Message = < <%= application.getAttribute("errorMessage") %>
>
> >
> > In my servlet I have:
> > application.setAttribute("errorMessage", "NO error message");
> >
> > esponse.sendRedirect( response.encodeRedirectURL("/userLoggedIn.jsp");
> >
> > The output is *always*: "Error Message = < null >". What the heck am I
> > doing wrong?
> >
>
> Milt Epstein
> Research Programmer
> Software/Systems Development Group
> Computing and Communications Services Office (CCSO)
> University of Illinois at Urbana-Champaign (UIUC)
> [EMAIL PROTECTED]
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html