java - How to get a query string for a url using httpUrlConnection , android -


I am using HttpUrlConnection to post a query on a webpage. The web page takes my request and does another posting, for example: www.unknown.com

  url = URL = "new URL" ("http://www.unknown.com"); // $ non-NLS-1 $ urlConnection = (HttpURL connection) url.openConnection (); UrlConnection.setReadTimeout (15 * 1000); UrlConnection.setDoInput (true); UrlConnection.setDoOutput (true); UrlConnection.setUseCaches (wrong); UrlConnection.setAllowUserInteraction (true); Out = New OutputStream Water (urlConnection.getOutputStream ()); String content = "var1 = 5" & var2 = 0 & var3 = 6 "; // $ Non-NLS-1 $ Out. Write (content); Out.flush (); Out.close ();   

The code is working without any problems and I am getting the html code. The problem is that the webpage is processing another HTTP "post" method when it is taking my request, for example after the request of the URI:

I received the value of "var4" in my code There is a need to do and I can not find any solution for this. HttpUrlConnection.getUrl () just gives the address! Is there any suggestion? Thank you.

How to use "getQuery ()" to retrieve the query string. string queries = url.getQuery ();

This will give you a question piece of this URL.

Use the string-locator to separate the parameters. (You have to apply the string-locator twice.)

Obtain a token from the first query string that is "& amp; This will return "val1 = 5", "val4 = 1500", etc.

The above tokens are applied once again to the Strontokanizer. This time, recover a different token from "=" Now repeat through this, the first token parameter name will be "val4", the second token value is "1500 " Will happen. New string signifier (query, "& amp;; false); // query is from getQuery (), whereas (st.hasMoreElements ()) {//" parametername = value "The first pass to withdraw the combo string, string paramValueToken = st.nextElement () .StringTokener StPaMVal = New StringTokenizer (Paravalet Token," = ", False); Int i = 0; while (stParamVal.hasMoreElements ()) {// "Separator" and "Price" to separate the second pass // First token is the absolute name // 2 token absolute value string different tout = stParamVal.nextE Lement (). ToString (); if (i == 0) {// indicates that this is the absolute name: ex val4, val5 etc. string paramname = separatedToken;} Else {// this parameter string is paramValue = separatedToken Will hold the value;} I ++;}}



Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -