aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Hi Please explain this.. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "Hi Please explain this.." Watch "Hi Please explain this.." New topic
Author

Hi Please explain this..

khushhal yadav
Ranch Hand

Joined: Jun 20, 2007
Posts: 242

Hi...

Please explain the below lines. and whether all the conditions must be met.

The following are the conditions that must be met before post FORM data will be populated to the
parameter set:
1. The request is an HTTP or HTTPS request.
2. The HTTP method is . POST
3. The content type is . application/x-www-form-urlencoded
4. The servlet has made an initial call of any of the 'getParameter' family of methods on the request object.

If the conditions are not met and the post form data is not included in the parameter set, the post data must still be available to the servlet via the request object's input stream. If the conditions are met, post form data will no longer be available for reading directly from the request object's input stream.

Regards,
Khushhal


rgrds,
Khushhal
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3327

Hi khushhal yadav,

Actually the request parameters sent via your HTTPRequest can be read in two forms. One in unformatted input streams and another in the formatted way which can be obtained via getInputParameter() methods.

If all the conditions are not met, they may not be available via getInputParameter() as they won't get formatted, but inturn they will definitely be available through InputStream but with the programmer's responsibility for formatting.

I think thats what it says. Does it somehow help you?


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3327

As per the Servlet 2.4 Specification it says,


SRV.14.2.14 ServletInputStream
public abstract class ServletInputStream extends java.io.InputStream
Provides an input stream for reading binary data from a client request, including
an efficient readLine method for reading data one line at a time. With some protocols,
such as HTTP POST and PUT, a ServletInputStream object can be used
to read data sent from the client.
A ServletInputStream object is normally retrieved via the
ServletRequest.getInputStream() method.
This is an abstract class that a servlet container implements. Subclasses of this
class must implement the java.io.InputStream.read() method.


This way, you will get the complete information but the request parameters will be available on the last few lines as the initial lines would have all the headers. So, its upto the programmer to split and get the required information.

Whereas, the getInputParameter() just gives you the values of the segregated-and-stored value of the parameters embedded in the request.
khushhal yadav
Ranch Hand

Joined: Jun 20, 2007
Posts: 242

Ok Raghavan,

But even if we use HTTP GET method, form data is included in the parameter set. But that is the query string data.
Post body data (if somehow that is there assume virtually) is not included. But that will be availbale for reading directly from InputStream.

Am i right, Raghvan?

Regards,
Khushhal
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3327


But even if we use HTTP GET method, form data is included in the parameter set. But that is the query string data.
Post body data (if somehow that is there assume virtually) is not included. But that will be availbale for reading directly from InputStream.

Am i right, Raghvan?


I think the whole scenario started in your question with POST request.

You need to remember that according to the method (Get or Post), the appropriate overloaded method (doGet() or doPost()) would be called by the service() method.

In such case, what you will be doing with the Post body data in the Get method's implementation if you pass it via GET method.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4725

Originally posted by Raghavan Muthu:
You need to remember that according to the method (Get or Post), the appropriate overloaded method (doGet() or doPost()) would be called by the service() method.

You mean the appropriate inherited or overridden method! :nono:


A good workman is known by his tools.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Hi Please explain this..
 
Similar Threads
any condition to populate parameter set??
Handling of post form data�
Query String
Ambiguity in servlet spec.
HTTP method GET is not supported by this URL