get attribute

what is the difference between request.getAttribute and request.getParamter
[82 byte] By [JK_JAVAa] at [2007-11-26 15:13:12]
# 1

> what is the difference between request.getAttribute

> and request.getParamter

getAttribute

public java.lang.Object getAttribute(java.lang.String name)Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.

Attributes can be set two ways. The servlet container may set attributes to make available custom information about a request. For example, for requests made using HTTPS, the attribute javax.servlet.request.X509Certificate can be used to retrieve information on the certificate of the client. Attributes can also be set programatically using setAttribute(java.lang.String, java.lang.Object). This allows information to be embedded into a request before a RequestDispatcher call.

Attribute names should follow the same conventions as package names. This specification reserves names matching java.*, javax.*, and sun.*.

Parameters:

name - a String specifying the name of the attribute

Returns:

an Object containing the value of the attribute, or null if the attribute does not exist

getParameter

public java.lang.String getParameter(java.lang.String name)Returns the value of a request parameter as a String, or null if the parameter does not exist. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.

You should only use this method when you are sure the parameter has only one value. If the parameter might have more than one value, use getParameterValues(java.lang.String).

If you use this method with a multivalued parameter, the value returned is equal to the first value in the array returned by getParameterValues.

If the parameter data was sent in the request body, such as occurs with an HTTP POST request, then reading the body directly via getInputStream() or getReader() can interfere with the execution of this method.

Parameters:

name - a String specifying the name of the parameter

Returns:

a String representing the single value of the parameter

Interface ServletConfig

A servlet configuration object used by a servlet container used to pass information to a servlet during initialization.

Interface ServletContext

public interface ServletContext

Defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file.

There is one context per "web application" per Java Virtual Machine. (A "web application" is a collection of servlets and content installed under a specific subset of the server's URL namespace such as /catalog and possibly installed via a .war file.)

In the case of a web application marked "distributed" in its deployment descriptor, there will be one context instance for each virtual machine. In this situation, the context cannot be used as a location to share global information (because the information won't be truly global). Use an external resource like a database instead.

The ServletContext object is contained within the ServletConfig object, which the Web server provides the servlet when the servlet is initialized.

Mr.Lazy F letme make it clear this is not a Quiz Test Forum.Itz not a question whether some one knows answer or not.....

We expect people to know minimal basics.

as far i know U r a Lazy Bug whose never prepared to put minimal effort to findout the answer.....

Mr.Lazy F ppl here rn't your fellow assitanta

better take time and to go through API documentation & Google by putting appropriate key words. :x

Before you waste a single char for posting your a Q & A Quiz Keys.

RahulSharnaa at 2007-7-8 9:04:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thanks for info and also for investing your precious time in answering my question.I guess even you were not aware of these answers bcos u just pasted whatever you could google.Copy -paste anyone can do it Mr .I asked this question bcos I had few confusions with it...Even I understand what is to be asked and what not.I never compelled you to reply to my question.you could have ignored it if you had lot of problems in answering it.I very well know this is not a quiz session.

JK_JAVAa at 2007-7-8 9:04:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
I know ppl are not my fellow assistant.and dont expect them to be also.As far as I understand you cannot help others in solving problems.
JK_JAVAa at 2007-7-8 9:04:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...