Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > ServletRequest.setAttribute question

Reply
Thread Tools

ServletRequest.setAttribute question

 
 
Joerg Gippert
Guest
Posts: n/a
 
      07-30-2003
Hi everyone!

I have an action servlet, that takes an attribute out of the request,
changes it and puts it back into the request. Now Im wonderring, if I have
to remove the old attribute first, using removeAttribute() or if the API
simply overwrites any existing attribute if the same name is used.

E.g
Myobject o = (Myobject)request.getSession().getAttribute("MYATT RIBUTE")
o.changevlaue = "bla";
request.getSession().setAttribute("MYATTRIBUTE");

or do I have to do a request.getSession().removeAttribute("MYATTRIBUTE" )
before I set the new one?

Thanks for any hint!

Regards,
Joerg


 
Reply With Quote
 
 
 
 
Wendy S
Guest
Posts: n/a
 
      07-30-2003
"Joerg Gippert" <(E-Mail Removed)> wrote
> I have an action servlet, that takes an attribute out of the request,
> changes it and puts it back into the request. Now Im wonderring, if I

have
> to remove the old attribute first, using removeAttribute() or if the API
> simply overwrites any existing attribute if the same name is used.


You don't have to remove first. It's most likely a Map of some kind holding
the request attributes, so a 'put' using an existing key will replace the
old reference with the new one.

--
Wendy in Chandler, AZ



 
Reply With Quote
 
 
 
 
Joerg Gippert
Guest
Posts: n/a
 
      07-30-2003

"Wendy S" <(E-Mail Removed)> schrieb im Newsbeitrag
news:bg9f9t$l8a$(E-Mail Removed)...
> "Joerg Gippert" <(E-Mail Removed)> wrote
> > I have an action servlet, that takes an attribute out of the request,
> > changes it and puts it back into the request. Now Im wonderring, if I

> have
> > to remove the old attribute first, using removeAttribute() or if the API
> > simply overwrites any existing attribute if the same name is used.

>
> You don't have to remove first. It's most likely a Map of some kind

holding
> the request attributes, so a 'put' using an existing key will replace the
> old reference with the new one.


Thanks for your reply. Should have tried it out myselfe before I post here.
Its late here already
Yes, a Map came across my mind as well. Just was a bit confused about the
wording in the API (getAttribute) where it says"Returns the value of the
named attribute as an Object" and I was afraid, that maybe two objects of
the same name (old and new one) exist somewhere after I put it back into the
session.

Thanks again for the quick answer!

Regards,
Joerg


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments