Get Query String Values JAVA










0















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!










share|improve this question






















  • 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















0















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!










share|improve this question






















  • 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













0












0








0








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!










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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

















  • 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












2 Answers
2






active

oldest

votes


















1














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");





share|improve this answer
































    0














    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







    share|improve this answer
























      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
      );



      );













      draft saved

      draft discarded


















      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









      1














      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");





      share|improve this answer





























        1














        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");





        share|improve this answer



























          1












          1








          1







          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");





          share|improve this answer















          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");






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 15 '18 at 8:46

























          answered Nov 15 '18 at 8:28









          Sagar ZalaSagar Zala

          2,37441337




          2,37441337























              0














              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







              share|improve this answer





























                0














                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







                share|improve this answer



























                  0












                  0








                  0







                  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







                  share|improve this answer















                  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








                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 15 '18 at 8:52

























                  answered Nov 15 '18 at 8:43









                  akshay ambaliyaakshay ambaliya

                  113




                  113



























                      draft saved

                      draft discarded
















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      這個網誌中的熱門文章

                      How to read a connectionString WITH PROVIDER in .NET Core?

                      In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

                      Museum of Modern and Contemporary Art of Trento and Rovereto