Author |
Message
|
nimisha.parihar |
Posted: Tue Nov 30, 2010 4:30 am Post subject: How to retrieve parameters set using POST method |
|
|
Apprentice
Joined: 03 Nov 2010 Posts: 41
|
How can i reteive parameters if client who is hitting the URL and setting parameters using POST method ?
Using GET method the parameters get appended in the "X-Query-String".
With POST i couldn't see any "X-Query-String" getting generated. Nor the parameters were available in any field in HTTP Input Header |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Nov 30, 2010 5:35 am Post subject: Re: How to retrieve parameters set using POST method |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
nimisha.parihar wrote: |
How can i retrieve parameters if client who is hitting the URL and setting parameters using POST method ?
Using GET method the parameters get appended in the "X-Query-String".
With POST i couldn't see any "X-Query-String" getting generated. Nor the parameters were available in any field in HTTP Input Header |
Have you looked at the HTTPServletRequest being passed as parameter on the post? Have you looked at the servlet request's attributes?
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
nimisha.parihar |
Posted: Tue Nov 30, 2010 5:37 am Post subject: |
|
|
Apprentice
Joined: 03 Nov 2010 Posts: 41
|
I am not getting HTTPServletRequest .
All i am getting is - HTTP Input Header. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Nov 30, 2010 5:47 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
HttpServlet:
Quote: |
doPost
protected void doPost(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
Called by the server (via the service method) to allow a servlet to handle a POST request. The HTTP POST method allows the client to send data of unlimited length to the Web server a single time and is useful when posting information such as credit card numbers.
When overriding this method, read the request data, write the response headers, get the response's writer or output stream object, and finally, write the response data. It's best to include content type and encoding. When using a PrintWriter object to return the response, set the content type before accessing the PrintWriter object.
The servlet container must write the headers before committing the response, because in HTTP the headers must be sent before the response body.
Where possible, set the Content-Length header (with the ServletResponse.setContentLength(int) method), to allow the servlet container to use a persistent connection to return its response to the client, improving performance. The content length is automatically set if the entire response fits inside the response buffer.
When using HTTP 1.1 chunked encoding (which means that the response has a Transfer-Encoding header), do not set the Content-Length header.
This method does not need to be either safe or idempotent. Operations requested through POST can have side effects for which the user can be held accountable, for example, updating stored data or buying items online.
If the HTTP POST request is incorrectly formatted, doPost returns an HTTP "Bad Request" message.
Parameters:
req - an HttpServletRequest object that contains the request the client has made of the servlet
resp - an HttpServletResponse object that contains the response the servlet sends to the client
Throws:
IOException - if an input or output error is detected when the servlet handles the request
ServletException - if the request for the POST could not be handled
See Also:
ServletOutputStream, ServletResponse.setContentType(java.lang.String)
|
This tells me that your parameters are somewhere in the stream. Best bet to go hunting for is the HttpServletRequest... and the context.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
nimisha.parihar |
Posted: Tue Nov 30, 2010 6:27 am Post subject: |
|
|
Apprentice
Joined: 03 Nov 2010 Posts: 41
|
I am sorry i am asking again. I have just a month experience on this and i m not sure how to go about this.
What i have done till now -
1. Used HTTPInputNode. Given my URL there.
2. Tried hitting the URL. The parameters are getting set in the JSP with the servlet code as follows -
public void doPost(HttpServletRequest request, HttpServletResponse resp)
throws ServletException, IOException {
HttpSession session1 = request.getSession(false);
String userid = null;
String password = null;
int count = 0;
if (request.getParameter("userid") != null
&& request.getParameter("password") != null) {
userid = request.getParameter("userid");
password = request.getParameter("password");
user.setPassword(password);
}
3. From MB - i get
Message --> Properties
Message --> HTTPInputHeader |
|
Back to top |
|
 |
mgk |
Posted: Tue Nov 30, 2010 6:40 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Try setting the body parser to BLOB and see in the parameters turn up there...
If not, post the output of a trace node after the HTTPInput node... _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
nimisha.parihar |
Posted: Tue Nov 30, 2010 9:20 am Post subject: |
|
|
Apprentice
Joined: 03 Nov 2010 Posts: 41
|
I have tried using BLOB but couldn't retrieve values. Its not coming in any of the headers.  |
|
Back to top |
|
 |
Vitor |
Posted: Tue Nov 30, 2010 9:31 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
nimisha.parihar wrote: |
I have tried using BLOB but couldn't retrieve values. Its not coming in any of the headers.  |
Prove it with a trace, as my most worthy associate has said. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mgk |
Posted: Tue Nov 30, 2010 9:37 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Quote: |
I have tried using BLOB but couldn't retrieve values. Its not coming in any of the headers |
It will not be in a header if it is not actually a query string. I suspect it will be in the body as x-www-form-urlencoded data or similar...
Kind Regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
nimisha.parihar |
Posted: Tue Nov 30, 2010 9:59 am Post subject: |
|
|
Apprentice
Joined: 03 Nov 2010 Posts: 41
|
Having a first look at the message doesnt really show that the values are there.
Will it be any encrypted format or will be be as is set in the jsp and sent using POST method ? |
|
Back to top |
|
 |
nimisha.parihar |
Posted: Tue Nov 30, 2010 10:00 am Post subject: |
|
|
Apprentice
Joined: 03 Nov 2010 Posts: 41
|
Can the JSP send parameters as Query String using POST Method ? |
|
Back to top |
|
 |
Vitor |
Posted: Tue Nov 30, 2010 10:03 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
nimisha.parihar wrote: |
Having a first look at the message doesnt really show that the values are there. |
Have a second look. In a trace, not the debugger. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
nimisha.parihar |
Posted: Tue Nov 30, 2010 11:39 pm Post subject: |
|
|
Apprentice
Joined: 03 Nov 2010 Posts: 41
|
Thanks all for all the help you guys extended.
I was successfully able to retrieve the parameters with the suggestions and ideas you guys gave
It was all about reading the message as a BLOB and then casting it to retrieve the original parameters... |
|
Back to top |
|
 |
|