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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Are getParameter and getAttribute interchangeable?" Watch "Are getParameter and getAttribute interchangeable?" New topic
Author

Are getParameter and getAttribute interchangeable?

mohammad shadab
Ranch Hand

Joined: Jul 09, 2013
Posts: 31

"can we use getParameter instead of getAttribute in servlet/jsp ???"
Ahsan Bagwan
Ranch Hand

Joined: Oct 05, 2010
Posts: 153
Your question is a bit vague.

Both of these methods have different purposes. If you want to submit a form or send a GET request to the server, you will always need a 'getParameter()' invoked on a request object to obtain form control values.

When you desire to use a value across subsequent page/many pages in an application use 'getAttribute()' and 'setAttribute()' method. For instance if you want to forward a message to a JSP from a servlet you place that message in the request scoped variable using setAttribute().

mohammad shadab
Ranch Hand

Joined: Jul 09, 2013
Posts: 31

Ahsan Bagwan wrote:Your question is a bit vague.

Both of these methods have different purposes. If you want to submit a form or send a GET request to the server, you will always need a 'getParameter()' invoked on a request object to obtain form control values.

When you desire to use a value across subsequent page/many pages in an application use 'getAttribute()' and 'setAttribute()' method. For instance if you want to forward a message to a JSP from a servlet you place that message in the request scoped variable using setAttribute().


as you said "If you want to submit a form or send a GET request to the server, you will always need a 'getParameter()" .is there any thing different for POST request???
Ahsan Bagwan
Ranch Hand

Joined: Oct 05, 2010
Posts: 153
No. I indeed meant POST when I referred to form submission (in the context that you want to change server state (like inserting employee record in db)).
mohammad shadab
Ranch Hand

Joined: Jul 09, 2013
Posts: 31

Ahsan Bagwan wrote:No. I indeed meant POST when I referred to form submission (in the context that you want to change server state (like inserting employee record in db)).
okay thank you ahsan bro...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Are getParameter and getAttribute interchangeable?
 
Similar Threads
Downloading HTML page
Un-downloadable Applets
Export in Excel
Capturing Form Data
WA #1.....word association