Help!!!.....HTTP Post to JSP with parameters in URL also....

I am trying to emulate a webpage that is POSTing info to a URL which is a JSP that also has parameters in the URL. I am having problems getting my java code to emulate doing this task manually through a web browser.
The webpage has the following HTML code:
<form method=post action=hello.jsp?y=60245&x=698>
<input type="text" name="name" value="jim">
<input type=submit name=submit value="Now">
</form>
...notice that the jsp referenced above has some parameters appended to the url, but the method is post.
Here's my code to try to do the same thing as if I manually pressed the submit button in a browser:
URL url = new URL("hello.jsp?y=60245&x=698");
httpConnection = (HttpURLConnection)url.openConnection();
httpConnection.setRequestMethod("POST");
httpConnection.setDoOutput(true);
httpConnection.setDoInput(true);
httpConnection.setUseCaches(false);
httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
DataOutputStream output = new DataOutputStream(httpConnection.getOutputStream());
output.writeBytes("name=jim&submit=Now");
output.flush();
BufferedReader is = new BufferedReader(new InputStreamReader(httpConnection.getInputStream()));
Writer w = new BufferedWriter(new FileWriter("CapturedHTML.html"));
int data=0,count=0;
while(data!=-1){
      data = is.read();
      w.write(data);
      count++;
System.out.println(count + " bytes read");
w.flush();
w.close();
is.close();
output.close();I write out the result to a file so that I can see the HTML returned by the JSP. It's a completely different webpage than if I were to have manually clicked the submit button on a browser.
WHY???????? How is a browser actually sending the info to the jsp when it has info both in its URL and in the post data?

I might be wrong, but the browser could have some sort of mechanism built into it which makes sure that the parameters appended to the url are actually passed as a part of a POST requst, while a Java program might not pass them at all.
Have you tried passing these params: y=60245&x=698 as a part of a POST request, rather than adding them to the URL.
Also, how do u know which response from JSP is correct? They might be different but do u know which one is the correct one? Do you know what the response should look like? that would make things a lot easier as u could figure out what parameters are causing the differences in the responses u r getting.

Similar Messages

  • HTTP POST using JSP

    Is it possible to submit a data using HTTP POST from a JSP. In a JSP I am generating a XML. For example JSP URL is http://www.test/xml.jsp
    In the xml.jsp:-
    <test>
    <test1>
    Testing 1
    </test1>
    <test2>
    Testing 2
    </test2>
    </test>
    When I call http://www.test/xml.jsp, I should receive the content in the xml.jsp as a HTTP POST. Is this possible using JSP or do I have to use only servlet?
    Thanks

    Hi,
    yes, it's possible to submit data from JSP using POST method.
    It is even possible to do it from HTML. Set <form method="post"...>, that's all. You can't submit data using POST by typing any specific address etc. in Your browser, only GET parameters can be sent in such a way.
    Regards, M

  • Configure HTTP POST on arrowpoint with version 5.00

    I configured the headers rule for http post but it´s doesn´t work.
    Someone have any idea..??
    This is the config.....thanks
    service wqa01-27
    ip address 172.16.51.27
    keepalive uri "/newadmin/admin/arrow.asp"
    keepalive frequency 35
    keepalive type http
    string wqa0127
    active
    service wqa02-27
    keepalive uri "/newadmin/admin/arrow.asp"
    keepalive frequency 35
    keepalive type http
    string wqa0227
    ip address 172.16.52.27
    active
    content ar-qa-post
    vip address 200.41.112.38
    protocol tcp
    port 80
    url "/*"
    advanced-balance arrowpoint-cookie
    arrowpoint-cookie advanced
    header-field-rule POST-METHOD weight 0
    add service wqa01-27
    add service wqa02-27
    active
    !********************* HEADER FIELD GROUP *********************
    header-field-group GET-METHOD
    header-field GET request-line contain "GET"
    header-field-group POST-METHOD
    header-field POST request-line contain "POST"

    Javier,
    I would suggest you to start with something basic and than add complexity.
    Create a very simple content rule with just an ip address. no port. no protocol.
    Then add one or more servers.
    Activate.
    Give it a try like this.
    Does it work ?
    If yes, define 'protocol tcp' and 'port 80'.
    Does it work ?
    If yes, configure 'url "/*"'
    does it work ?
    If yes, configure 'advanced-balance arrowpointcookie'
    This config is explained at
    http://www.cisco.com/en/US/products/hw/contnetw/ps789/products_tech_note09186a0080094398.shtml
    It it does not work, tell us what is not working.
    Is it the stickyness that does not work or you can't even connect to the vip address ?
    Also collect a sniffer trace on client and server.
    Thanks,
    Gilles.

  • Calling Transaction SP01 (Display spool requests) with parameters via URL

    Hi,
    I would like to be able to list all spool requests of a certain title via a URL.
    Unfortunately ITS does not seem to work. A URL constructed like this
    http://host:port/sap/bc/gui/sap/its/webgui/!?sap-system-login-basic_auth=X&sap-client=500&sap-language=EN&transaction=SP01&S_RQTITL-LOW=Testing123&okcode=CRET
    causes a short dump that SP01 (Program RSOSP01NR) is a Module Pool.
    I am therefore considering the following options:
    1. BSP Program
    2. Java WebDynpro
    3. ABAP WebDynpro
    Ideally, I want to be able to enter in my browser something like
    http://host:port/<BSP_or_WebDynPro_stuff>&~title=Testing123
    and for this to show in the browser a list of all spool requests that are named "Testing123".
    Can someone advise whether any of the above options are preferable?
    Also, whether such a program should call transaction SP01 with parameters (skipping first screen) or look to using the associated function modules.
    Many thanks for any assistance.
    Regards
    Adrian

    Solved myself. Thanks

  • Reading Parameters of a http post in JSP

    I am migrating a Data Web Bean that extends EditCurrentRecord from JDev 3.1 to 3.2
    In old 3.1 days, one could read the HTTP parameters using request.getParameter(). Now, the implementation of EditCurrentRecord uses an OrdHttpUploadRequest to read the parameters, which is not (!) documentated nor included as source file. Given the library.ini configuration, it belongs to some intermedia stuff ???
    I somewhat understand the need for OrdHttpUploadRequest to deal with large files, but why doesn't request.getParameter work any more ? Has it something to do with Serverl 2.1 / 2.2 API ?
    Pascal

    The EditCurrentRecord now uses the multipart mime type in order to support interMedia. This causes the Http parameters to be in a different format that the OrdHttpRequest can decode.
    null

  • Help running a simple jsp (with struts and core -sun- taglibs)

    Hi, could somebody help me with this simple JSP?
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
         pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
         xmlns:c="http://java.sun.com/jsp/jstl/core"
         xmlns:html="http://struts.apache.org/tags-html">
    <head>
         <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    </head>
    <body>
         <html:text property="text">text</html:text>
         <label>hello</label>
         <c:forEach begin="1" end="5">
              <label>inside</label>
         </c:forEach>
    </body>
    </html>When I run it, the c:forEach tag doesn’t work.
    Output shows “text hello inside” instead of desired “text hello inside inside inside inside inside”
    Any hints will be really appreciated.
    Edited by: 792625 on 03-sep-2010 0:15

    Add the JSTL Core tag library.
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

  • Need help about Post  goods movement with refernece to Inbound delivery

    Hi All,
    I am using  FMs MB_CREATE_GOODS_MOVEMENT and MB_POST_GOODS_MOVEMENT and commit to create a goods movement. I am successfully creating the MM doc and also posting.But still the Inbound delivery is open for GR.Is there any other function module or BAPI that creates GR with reference to Inbound delivery and update the document flow?Or is there any parameter in the above FM that sets the inbound delivery.Kindly provide your guidance on the same.
    Best Regards,
    Sailaja.

    I used BAPI_GOODSMVT_CREATE and it posted the GR successfully and the document flow was updated also.
    You have to use GM_code '01' and give the delivery number / item number w/o PO (if I gave the PO additionally, it also worked).
    If still your document flow is not updated then have a look at OSS note 1050944 and check your config.

  • Unknown information sent with parameters to URL

    Hi all.
    I'm trying to send two paramerters (userid and password) to a URL using URLConnection. Here's the problem, it looks like the parameters are sent ok but when the page displays it says the userid is incorrect. And indeed, the userid is incorrect because it has appended to it my local machine name! Where is that coming from? Any ideas?
       URL url = new URL("http://nttestserver/servlets/myservlet/");
       URLConnection connection =url.openConnection();
       connection.setDoOutput(true);
       PrintWriter out = new PrintWriter(
         connection.getOutputStream());
       out.println("&userid=myuserid&pwd=testpwd");
       out.close();I end up with an error message because userid is being received as: myuserid@MPATHYIL_NT

    It's okay, I found the code I had stored (was looking for it before I posted the previous message):               URL servlet = new URL("http://127.0.0.1:8101/develop/servletName");
                   URLConnection con = servlet.openConnection();
                   con.setDoOutput(true);
                   con.setDoInput(true);
                   con.setUseCaches(false);
                   con.setRequestProperty("userid","myuserid");               con.setRequestProperty("format","value");
    It's the URLConnection.setRequestProperty() method you need.
    Cheers,
    Anthony

  • Http get to Http post

    Hello.
    Currently the Http receiver adapter is configured as HTTP get . We need to change it to HTTP Post and put the parameters in the URL in the body.
    Can someone please give an example on how to conevert a http get to http post. Is it a simple thing to do or does it need some java programming?
    Thanks for your help.
    Best Regards,
    Teresa

    Thanks Baskar. I am on SAP PI 7.1 Currently they have a HTTP_DESTINATION that is defined in SM59 and a Prolog. We want to change it to HTTP Post.
    Below is how it is configured currently -
    addressing type : HTTP Destination
    HTTP Destination : UPS_DESTINATION
    Content Type : application/x-www-form-urlencoded
    XML Code : UTF-8
    Prolog : arg1=
    Epilog = &action=generateUPSShippingLabel&format=xml
    How would I change above to HTTP post ?
    Teresa

  • Listen for HTTP Post in Flex

    Hello,
    I just have a simple question.  In my Flex program, I am trying to find a way to listen for an incoming HTTP POST message - something with functionality similar to that of the HttpListener class in C#.  I have not been able to find anything at all to help with this though, would anyone know of something like this?
    Thanks.

    My Flex program subscribes to changes that occur in a program on remote server.  The change notifications are sent back to my client in the form of an HTTP Post message.  The Flex program needs to be able to detect when these Posts are received.

  • HTTP post when a checkbox has been ticked (onclick event)?

    Is there a way to do a http post for every onclick event on check boxes?
    I need to post some data with parameters to an API or something that can be sent a HTTP post.

    OK, just wanted to make sure. Have a look at the Net.HTTP object. It has a single method, request, which allows you to exeute an HTTP request such as GET, POST, etc. But read the documentation well, there are some serious limitations on this method. The main one being that is has to be executed from a folder-level script.
    Alternatively, you can use the app.launchURL() method to open a web-page. The user will have to allow it, though.

  • How to Invoke service using HTTP POST in BPEL?

    I have a client using .net service with a web page http://.../httpreceive.aspx which is invoke through an http post. How can we post xml message using http post to the url in BPEL. Are there any documentation on doing this? Will this require writing a java class to do an http post the xml message to the url?
    Edited by: sns724 on Feb 12, 2009 11:56 AM

    I created a wsdl with the http-binding to do a HTTP Post and I'm getting a com.collaxa.cube.ws.wsif.providers.http.WSIFOperation_HTTP@1ac9964 : Could not invoke 'process'; nested exception is: java.lang.NullPointerException.
    Here's my wsdl with the binding:
    <definitions name="TestHTTPost" targetNamespace="http://test.com"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://test.com"
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
    xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
    <types>
    <schema attributeFormDefault="qualified" elementFormDefault="qualified"
    targetNamespace="http://hyphen.com"
    xmlns="http://www.w3.org/2001/XMLSchema">
    <element name="AddressBookEntry">
    <complexType>
    <sequence>
    <element name="AddressBookNumber" type="string"/>
    <element name="Name" type="string"/>
    <element name="AddressLine1" type="string"/>
    <element name="AddressLine2" type="string"/>
    <element name="City" type="string"/>
    <element name="State" type="string"/>
    <element name="PostalCode" type="string"/>
    <element name="Phone" type="string"/>
    <element name="Fax" type="string"/>
    <element name="Email" type="string"/>
    <element name="ElectDest" type="string"/>
    </sequence>
    </complexType>
    </element>
    <element name="PostMessageResult">
    <complexType>
    <sequence>
    <element name="Result" type="string"/>
    <element name="Errors">
    <complexType>
    <sequence>
    <element name="Error">
    <complexType>
    <sequence>
    <element name="ErrorDescription" type="string"/>
    <element name="ErrorSource" type="string"/>
    </sequence>
    </complexType>
    </element>
    </sequence>
    </complexType>
    </element>
    </sequence>
    </complexType>
    </element>
    </schema>
    </types>
    <message name="HTTPPostServiceRequestMessage">
    <part name="payload" element="tns:AddressBookEntry"/>
    </message>
    <message name="HTTPPostServiceResponseMessage">
    <part name="payload" element="tns:PostMessageResult"/>
    </message>
    <portType name="HTTPPostService">
    <operation name="process">
    <input message="tns:HTTPPostServiceRequestMessage" />
    <output message="tns:HTTPPostServiceResponseMessage"/>
    </operation>
    </portType>
    <binding name="HTTPPost" type="tns:HTTPPostService">
    <http:binding verb="POST"/>
    <operation name="process">
    <http:operation location="/httpreceive.aspx"/>
    <input>
    <mime:mimeXml part="payload"/>
    <mime:content type="text/xml"/>
    </input>
    <output>
    <mime:mimeXml part="payload"/>
    <mime:content type="text/xml"/>
    </output>
    </operation>
    </binding>
    <service name="HTTPPostService">
    <port name="HTTPPost" binding="tns:HTTPPost">
    <http:address location="https://testxml.solutions.com"/>
    </port>
    </service>
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PARTNER LINK TYPE DEFINITION
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <plnk:partnerLinkType name="HTTPPostService">
    <plnk:role name="HTTPPostServiceProvider">
    <plnk:portType name="tns:HTTPPostService"/>
    </plnk:role>
    </plnk:partnerLinkType>
    </definitions>

  • Applicatio​n using Http Post... getting error response

    Im from Ecuador, and me and other 4 people from the same country are getting this error response when a native java application is trying to make a http post to mydomain.com
    The requested URL could not be retrieved:
    While trying to process the request:
    POST /somedir/more?var1=abc&var2=xyz& HTTP/1.1
    Expect: 100-continue
    Host: mydomain.com
    Content-Length: 40
    Content-Type: text/plain; charset=utf-8
    Accept: */*
    Connection: close
    Invalid request. Some aspect of the HTTP Request is nivalid. Possible problems:
    Missing or unknwon request method
    Missing URL
    Missing HTTP Identifier (HTTP/1.0)
    Request is too large
    Content-Length missing for POST or PUT request
    Generated by Blackberry.Internet.Browsing.Service (squd/2.7.STABLE6)
    This issue is only happening in my country (Ecuador). I have some friends in Argentina and they have no problems at all. What are the posible causes for this problem?
    Message Edited by andufo on 07-09-2009 08:43 PM

    Hi again,
    im attaching all the info you request:
    What does the program actually do?
    Social network (because of the TOS of this forum im not allowed to post project names or urls)
    What is it trying to send when you submit a request?
    What url is it posting the information to? 
    Im attaching all this at the end of the post.
    Is it the 'exact' same application that works in other countries?
    Yeap, the exact same one...
    Is it supposed to be useing the Internet Browser?
    No, it is a native app. The Browser is not used at all.
    Are you on a BlackBerry Enterprise Server? 
    Im on BIS, all the users use BIS.
    Technical details:
    1) The app makes an Http Connection (POST) to:
    http://mydomain.com/api/call?param1=abc&param2=xyz
    2) This is the Http connection configuration:
    httpConnection = (HttpConnection) Connector.open(url);
    HttpConnection.POST;
    ("Content-Type", "text/plain; charset=utf-8");
    ("Host", 'mydomain.com');
    ("Content-Length", 100); //depends on sent data
    ("User-Agent", 'BlackBerry8300... etc');
    ("Expect", "100-continue");
    3) On every country it works fine... on my country i get this error:
    The requested URL could not be retrieved while trying to process the request:
    POST /app/llamada?param1=abc&param2=xyz& HTTP/1.1
    - Expect: 100-continue
    - Host: mydomain.com
    - Content-Length: 100
    - Content-Type: text/plain; charset=utf-8
    - Accept: */*
    - Connection: close
    Invalid request. Some aspect of the HTTP Request is invalid. Possible problems:
    - Missing or unknwon request method
    - Missing URL
    - Missing HTTP Identifier (HTTP/1.0)
    - Request is too large
    - Content-Length missing for POST or PUT request
    Generated by Blackberry.Internet.Browsing.Service (squid/2.7.STABLE6)

  • Help! How to reset G770 BIOS password? Also blue screen 0x00000050 PAGE_FAULT_IN_NONPAGED_AREA

    Short story: After automatic updates every boot ends up with blue screen. I need to access BIOS to set the factory defaults, but the the guy i bought this laptop from forgot the password he put on BIOS...
    Long story: One morning i was shutting down my laptop and automatic updates started, i haven't got time to wait so i closed the lid and left. Came back home, opened the lid, updating resumed and completed, restart - since then i never saw my Win 7...=( laptop crashes everytime with blue screen error 0x00000050 PAGE_FAULT_IN_NONPAGED_AREA even in safe mode... If you click on this link you can see the topic i've created at Microsoft Forum.
    Full story: I got myself a G770 about a year ago, swapped i5 to i7, 750GB HDD to 120GB SSD, it was flying!!! Few months later GPU failed, then CPU, apparently they were fried due to insufficient cooling (probably crappy cheap paste i used), had to put original i5 back. Later battery failed so i decided to send it for warranty service repair. My work is highly computer-dependent so i got myself another G770 as a temporary replacement, took my SSD from the old laptop, put in the new one - no problem, until it failed after automatic updates, as explained in the "Long story"...
    I really need your help guys, first of all with BIOS password, but also with getting my old Win 7 back to life, i don't even mind making a small "donation" for anyone who helps to sort this out for me. I work mainly with graphics/video software and i have apps perfectly set up to my needs with profiles etc and it would be a total nightmare to do a fresh install... Please...

    Hi Gintaras, welcome to the forum,
    you will need to get the previous owner to remember the password or another option would be to contact Lenovo service with a view to obtaining a new mainboard for your system.
    Discussion on subverting passwords is forbidden in these forums.
    No posts shall include instructions or directions intended to subvert security measures, including passwords, locking mechanisms, fingerprint scans, etc, nor shall any posts provide descriptions to the location of, nor direct links to content related to these topics.
    Sorry, I have to lock the thread
    Andy  ______________________________________
    Please remember to come back and mark the post that you feel solved your question as the solution, it earns the member + points
    Did you find a post helpfull? You can thank the member by clicking on the star to the left awarding them Kudos Please add your type, model number and OS to your signature, it helps to help you. Forum Search Option T430 2347-G7U W8 x64, Yoga 10 HD+, Tablet 1838-2BG, T61p 6460-67G W7 x64, T43p 2668-G2G XP, T23 2647-9LG XP, plus a few more. FYI Unsolicited Personal Messages will be ignored.
      Deutsche Community     Comunidad en Español    English Community Русскоязычное Сообщество
    PepperonI blog 

  • Http post with parameters

    Hi All,
    We want to send an HTTP post with parameters,  and we are not sure how to do that.  We tried to do that like the code below,but we get the parameters in the body and not in the header ...
      DATA lo_client      TYPE REF TO  if_http_client.
      DATA lv_status_code TYPE i.
      DATA lv_reason      TYPE string.
      CALL METHOD cl_http_client=>create_by_destination
        EXPORTING
          destination  = 'ZRFC_TEST'
        IMPORTING
          client       = lo_client.
      lo_client->request->set_method( if_http_request=>co_request_method_post ).
      cl_http_utility=>set_request_uri( request = lo_client->request
                                        uri     = '?param1=value1' ).
      lo_client->send( ).
      lo_client->receive( ).
      lo_client->response->get_status( IMPORTING code   = lv_status_code
                                                 reason = lv_reason ).
    Thanks a lot,
    Tuvia.

    Hi,
    what do you mean by "parameters on the query". In any http request you can have two types of variables: POST or GET. The post variables are transferred in http header and you can add them using methods from my previous post. GET variables are transferred in URL. HTTP client has a method APPEND_FIELD_URL which can be used to add variable into URL string.
    Cheers

Maybe you are looking for