Re: request.setAttribute() fails to set attribute - help



phillip.s.powell@xxxxxxxxx wrote:

> request.setAttribute("message", (Object)URLEncoder.encode(message,
> "UTF-8"));
> request.setAttribute("nickname", (Object)URLEncoder.encode(cookie,
> "UTF-8"));
> out.println("message = " + request.getParameter("message") + " and
> nickname = " + request.getParameter("nickname"));
[...]
> When viewing the contents via out and you click the "Send" button, you
> get this:
>
> [quote]message = blah blah blah and nickname = null[/quote]
>
> When viewing the contents via out and you click the "Quit" button, you
> get this:
>
> [quote]message = and nickname = null[/quote]
>
> How is this possible when I'm setting request.setAttribute()
> beforehand? Is there something else I need to do to alter or add values
> to HttpServletRequest request before submitting it as parameter to
> MessageProcessor?

I'm not sure if I understand your problem, but if you set something
with setAttribute, shouldn't you use getAttribute for getting
the attribute again? getParameter returns the value for a given
querystring-entry, e.g.

http://somehost.invalid/path/servlet?key=value

key=value is the querystring and request.getParameter("key")
should return "value". Maybe there is a setParameter-method
(I dont' have the Servlet-API at hand right now) you can use
and solve your problem.


Regards, Lothar
--
Lothar Kimmeringer E-Mail: spamfang@xxxxxxxxxxxxxx
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
questions!
.