Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hi Please explain this..

 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic