wood burning stoves 2.0*
The moose likes Servlets and the fly likes getAttribute() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "getAttribute()" Watch "getAttribute()" New topic
Author

getAttribute()

VENKATESH NADAGOUDA
Greenhorn

Joined: Jan 29, 2003
Posts: 7
can we use getAttribute() to read the contents of querystring.If not why
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Yes, that's the exact right method to use.

If you are trying and having trouble, post some of your code.

My first question would be: do you have a file upload form element in the form? If so, this will not play nicely with getAttribute()
Dominic Paquette
Ranch Hand

Joined: Dec 13, 2002
Posts: 64
Hi,
Did you try HttpServletResponse.getQueryString() ?
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
getQueryString() is actually a method of HttpServletRequest.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
VENKATESH NADAGOUDA
Greenhorn

Joined: Jan 29, 2003
Posts: 7
Dear All
Firstly thank u,
now which is more advantageous getAttribute() or getParameter()
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

You know what? I'm totally out to lunch. I must have had a brain freeze.

If you are submitting a form, or click on a link that contains name/value pairs, then the way to get these items is with getParameter()

So if the URL to the servlet looks like:

http://www.localhost:8080/app/servlet1?name=foo&name2=bar

then here is how you access the name and name2 parameters...


When you programatically *add* things to a request or a session, the way to get these 'extra' things is within the attribute space. setAttribute() and getAttribute() are used for this purpose. Only those things that you "set" with setAttribute can be "gotten" with getAttribute.

Sorry for that confusion!
VENKATESH NADAGOUDA
Greenhorn

Joined: Jan 29, 2003
Posts: 7
Hi,
Thanks Mike.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getAttribute()
 
Similar Threads
getParameter()
returning an array from servlet responce
A Problem from HeadFirst Servlet & JSP(CHAP-3)
c:set and scope
Modifying the request object ?