As I explained in a previous posting, my code didn't work because I had my
JSPs in the wrong directory -- one that wasn't under my app tree.  Then,
when my servlet redirected to the JSP, Tomcat considered it part of a
different app.  :)  I.e., the call was fine, it was a completely different
problem that caused the failure.

I've been programming in Java 5 years.  I've taught the language in
college.  A string literal is a String.  A String is a type of Object.  The
call is fine.  And note that because Java is strongly typed, that if it
wasn't a valid Object, there would have been a compilation error.  Really.

-- Jim

At 06:39 PM 12/18/2001, you wrote:
>Then explain why getServletContext().setAttribute("string", "string")
>doesn't work!
>
>Mark
>
>This email scanned with Norton AntiVirus 2002
>
>
>----- Original Message -----
>From: "Christopher K. St. John" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Tuesday, December 18, 2001 10:04 PM
>Subject: Re: Communication between JSP and servlets
>
>
> > Mark Galbreath wrote:
> >
> > > there is (a) a definite difference between a string (literal) and
> > > a String (object) when it comes to some of the API methods.
> > >
> >
> >  No, there is no difference at all. A string literal
> > is an Object of class String. The language spec is
> > very explicit on this point.
> >
> >
> > > (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.
> > >
> >
> >  A string literal is a String, and a String is an
> > Object. There is nothing special about how equals()
> > handles string literals. You can go look at the
> > source to String.equals(), it's completely
> > straightforward how it works: it checks if the
> > argument is the same object, then it compares the
> > characters one by one.
> >
> >
> > Colin Capriati wrote:
> > >
> > > For brevity you could also try:
> > > application.setAttribute("errorMessage",new String("NO Error Message"));
> > >
> >
> >  There is no need to create a new String, or do any
> > casting, or anything like that. The call is perfectly
> > fine as:
> >
> >  application.setAttribute("errorMessage", "This is an error message")
> >
> >
> >  This thread has been filled to bursting with
> > incorrect information guaranteed to confuse the
> > newbies in the audience. Can we please just stop
> > the madness and get back on-topic?
> >
> >
> > -cks
> >
> >
>___________________________________________________________________________
> > 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

___________________________________________________________________________
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

Reply via email to