Get Query String Values JAVA
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I wanted to know if someone can help me with getting the values from a query string.
This is the example: partygo://qr/?partyId=XXX&uid=XXX&name=XXX
I want to get the values from partyId, uid and name. I really dont know if there is any encoder or sth like that.
Thanks!
java android
add a comment |
I wanted to know if someone can help me with getting the values from a query string.
This is the example: partygo://qr/?partyId=XXX&uid=XXX&name=XXX
I want to get the values from partyId, uid and name. I really dont know if there is any encoder or sth like that.
Thanks!
java android
maybe this other question can help you
– justo
Nov 15 '18 at 8:22
Maybe use a REGEX and retrieve your value with that?
– dnsiv
Nov 15 '18 at 9:03
add a comment |
I wanted to know if someone can help me with getting the values from a query string.
This is the example: partygo://qr/?partyId=XXX&uid=XXX&name=XXX
I want to get the values from partyId, uid and name. I really dont know if there is any encoder or sth like that.
Thanks!
java android
I wanted to know if someone can help me with getting the values from a query string.
This is the example: partygo://qr/?partyId=XXX&uid=XXX&name=XXX
I want to get the values from partyId, uid and name. I really dont know if there is any encoder or sth like that.
Thanks!
java android
java android
asked Nov 15 '18 at 8:19
Franco EstevezFranco Estevez
85
85
maybe this other question can help you
– justo
Nov 15 '18 at 8:22
Maybe use a REGEX and retrieve your value with that?
– dnsiv
Nov 15 '18 at 9:03
add a comment |
maybe this other question can help you
– justo
Nov 15 '18 at 8:22
Maybe use a REGEX and retrieve your value with that?
– dnsiv
Nov 15 '18 at 9:03
maybe this other question can help you
– justo
Nov 15 '18 at 8:22
maybe this other question can help you
– justo
Nov 15 '18 at 8:22
Maybe use a REGEX and retrieve your value with that?
– dnsiv
Nov 15 '18 at 9:03
Maybe use a REGEX and retrieve your value with that?
– dnsiv
Nov 15 '18 at 9:03
add a comment |
2 Answers
2
active
oldest
votes
Solution 1:
By decoding the parameters like below,
public void getParametersFromRequest(HttpServletRequest request, HttpServletResponse response)
String partyId = request.getParameter("partyId");
String uid= request.getParameter("uid");
String name= request.getParameter("name");
Solution 2:
You can achieve this using below method.
public static Map<String, String> getQueryMap(String query)
String params = query.split("&");
Map<String, String> map = new HashMap<String, String>();
for (String param : params)
String p=param.split("=");
String name = p[0];
if(p.length>1)
String value = p[1];
map.put(name, value);
return map;
So then you can use:
Map params=getQueryMap(querystring);
String partyId=(String) params.get("partyId");
String uid=(String) params.get("uid");
String name=(String) params.get("name");
add a comment |
This is simple GET request so you can directly get the value of query string using the request object in doGet method
public void doGet(HttpServletRequest request, HttpServletResponse response)
String partyid = request.getParameter("partyId");
//similar do others
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53315054%2fget-query-string-values-java%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Solution 1:
By decoding the parameters like below,
public void getParametersFromRequest(HttpServletRequest request, HttpServletResponse response)
String partyId = request.getParameter("partyId");
String uid= request.getParameter("uid");
String name= request.getParameter("name");
Solution 2:
You can achieve this using below method.
public static Map<String, String> getQueryMap(String query)
String params = query.split("&");
Map<String, String> map = new HashMap<String, String>();
for (String param : params)
String p=param.split("=");
String name = p[0];
if(p.length>1)
String value = p[1];
map.put(name, value);
return map;
So then you can use:
Map params=getQueryMap(querystring);
String partyId=(String) params.get("partyId");
String uid=(String) params.get("uid");
String name=(String) params.get("name");
add a comment |
Solution 1:
By decoding the parameters like below,
public void getParametersFromRequest(HttpServletRequest request, HttpServletResponse response)
String partyId = request.getParameter("partyId");
String uid= request.getParameter("uid");
String name= request.getParameter("name");
Solution 2:
You can achieve this using below method.
public static Map<String, String> getQueryMap(String query)
String params = query.split("&");
Map<String, String> map = new HashMap<String, String>();
for (String param : params)
String p=param.split("=");
String name = p[0];
if(p.length>1)
String value = p[1];
map.put(name, value);
return map;
So then you can use:
Map params=getQueryMap(querystring);
String partyId=(String) params.get("partyId");
String uid=(String) params.get("uid");
String name=(String) params.get("name");
add a comment |
Solution 1:
By decoding the parameters like below,
public void getParametersFromRequest(HttpServletRequest request, HttpServletResponse response)
String partyId = request.getParameter("partyId");
String uid= request.getParameter("uid");
String name= request.getParameter("name");
Solution 2:
You can achieve this using below method.
public static Map<String, String> getQueryMap(String query)
String params = query.split("&");
Map<String, String> map = new HashMap<String, String>();
for (String param : params)
String p=param.split("=");
String name = p[0];
if(p.length>1)
String value = p[1];
map.put(name, value);
return map;
So then you can use:
Map params=getQueryMap(querystring);
String partyId=(String) params.get("partyId");
String uid=(String) params.get("uid");
String name=(String) params.get("name");
Solution 1:
By decoding the parameters like below,
public void getParametersFromRequest(HttpServletRequest request, HttpServletResponse response)
String partyId = request.getParameter("partyId");
String uid= request.getParameter("uid");
String name= request.getParameter("name");
Solution 2:
You can achieve this using below method.
public static Map<String, String> getQueryMap(String query)
String params = query.split("&");
Map<String, String> map = new HashMap<String, String>();
for (String param : params)
String p=param.split("=");
String name = p[0];
if(p.length>1)
String value = p[1];
map.put(name, value);
return map;
So then you can use:
Map params=getQueryMap(querystring);
String partyId=(String) params.get("partyId");
String uid=(String) params.get("uid");
String name=(String) params.get("name");
edited Nov 15 '18 at 8:46
answered Nov 15 '18 at 8:28
Sagar ZalaSagar Zala
2,41151438
2,41151438
add a comment |
add a comment |
This is simple GET request so you can directly get the value of query string using the request object in doGet method
public void doGet(HttpServletRequest request, HttpServletResponse response)
String partyid = request.getParameter("partyId");
//similar do others
add a comment |
This is simple GET request so you can directly get the value of query string using the request object in doGet method
public void doGet(HttpServletRequest request, HttpServletResponse response)
String partyid = request.getParameter("partyId");
//similar do others
add a comment |
This is simple GET request so you can directly get the value of query string using the request object in doGet method
public void doGet(HttpServletRequest request, HttpServletResponse response)
String partyid = request.getParameter("partyId");
//similar do others
This is simple GET request so you can directly get the value of query string using the request object in doGet method
public void doGet(HttpServletRequest request, HttpServletResponse response)
String partyid = request.getParameter("partyId");
//similar do others
edited Nov 15 '18 at 8:52
answered Nov 15 '18 at 8:43
akshay ambaliyaakshay ambaliya
113
113
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53315054%2fget-query-string-values-java%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
maybe this other question can help you
– justo
Nov 15 '18 at 8:22
Maybe use a REGEX and retrieve your value with that?
– dnsiv
Nov 15 '18 at 9:03