How to get text between tag in servlet The 2019 Stack Overflow Developer Survey Results Are In Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceHow do you remove all the options of a select box and then add one option and select it with jQuery?How to make the first option of <select> selected with jQueryWhat is the difference between JSF, Servlet and JSP?How to upload files to server using JSP/Servlet?How do servlets work? Instantiation, sessions, shared variables and multithreadingHow to use Servlets and Ajax?Jsp and Servlet HandlingUnable to fetch the value selected from a dropdown using JSPselect2 with dependent dynamic dropdown PHP/JQueryHow to call a DAO method from a Json Servlet

Separating matrix elements by lines

Didn't get enough time to take a Coding Test - what to do now?

Is an up-to-date browser secure on an out-of-date OS?

1960s short story making fun of James Bond-style spy fiction

Why are PDP-7-style microprogrammed instructions out of vogue?

Loose spokes after only a few rides

Drawing arrows from one table cell reference to another

Simulating Exploding Dice

What aspect of planet Earth must be changed to prevent the industrial revolution?

Visa regaring travelling European country

How to determine omitted units in a publication

Did the new image of black hole confirm the general theory of relativity?

Was credit for the black hole image misappropriated?

Is there a way to generate uniformly distributed points on a sphere from a fixed amount of random real numbers per point?

Variable with quotation marks "$()"

How do you keep chess fun when your opponent constantly beats you?

Is there a writing software that you can sort scenes like slides in PowerPoint?

Match Roman Numerals

Why not take a picture of a closer black hole?

How did the audience guess the pentatonic scale in Bobby McFerrin's presentation?

ELI5: Why do they say that Israel would have been the fourth country to land a spacecraft on the Moon and why do they call it low cost?

What can I do if neighbor is blocking my solar panels intentionally?

Can we generate random numbers using irrational numbers like π and e?

Make it rain characters



How to get text between tag in servlet



The 2019 Stack Overflow Developer Survey Results Are In
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceHow do you remove all the options of a select box and then add one option and select it with jQuery?How to make the first option of <select> selected with jQueryWhat is the difference between JSF, Servlet and JSP?How to upload files to server using JSP/Servlet?How do servlets work? Instantiation, sessions, shared variables and multithreadingHow to use Servlets and Ajax?Jsp and Servlet HandlingUnable to fetch the value selected from a dropdown using JSPselect2 with dependent dynamic dropdown PHP/JQueryHow to call a DAO method from a Json Servlet



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have select in my index page. It looks like below



<div id="dropdown" class="input-group" style="width:50%">
<select class="form-control" id="select2" name="select2" onchange="javascript:document.form1.submit();" style="width : 250px">
<option value="C:/path1" >option 1/option>
<option value="C:/path2" >option 2</option>
<option value="C:/path3" >option 3</option>
<option value="C:/path4" >option 4</option>
<option value="C:/path5" >option 5</option>
<option value="C:/path6" >option 6</option>
</select>
</div>


I need value of "Value" attribute i.e., "C:/path1" which I'm able to fetch in Servlet using



String value= request.getParameter("select2");


Now I need to fetch text between tag i.e., I need "option 1" or anything based on selection. How can I do it. Kindly help. Thanks in advance :)










share|improve this question




























    0















    I have select in my index page. It looks like below



    <div id="dropdown" class="input-group" style="width:50%">
    <select class="form-control" id="select2" name="select2" onchange="javascript:document.form1.submit();" style="width : 250px">
    <option value="C:/path1" >option 1/option>
    <option value="C:/path2" >option 2</option>
    <option value="C:/path3" >option 3</option>
    <option value="C:/path4" >option 4</option>
    <option value="C:/path5" >option 5</option>
    <option value="C:/path6" >option 6</option>
    </select>
    </div>


    I need value of "Value" attribute i.e., "C:/path1" which I'm able to fetch in Servlet using



    String value= request.getParameter("select2");


    Now I need to fetch text between tag i.e., I need "option 1" or anything based on selection. How can I do it. Kindly help. Thanks in advance :)










    share|improve this question
























      0












      0








      0








      I have select in my index page. It looks like below



      <div id="dropdown" class="input-group" style="width:50%">
      <select class="form-control" id="select2" name="select2" onchange="javascript:document.form1.submit();" style="width : 250px">
      <option value="C:/path1" >option 1/option>
      <option value="C:/path2" >option 2</option>
      <option value="C:/path3" >option 3</option>
      <option value="C:/path4" >option 4</option>
      <option value="C:/path5" >option 5</option>
      <option value="C:/path6" >option 6</option>
      </select>
      </div>


      I need value of "Value" attribute i.e., "C:/path1" which I'm able to fetch in Servlet using



      String value= request.getParameter("select2");


      Now I need to fetch text between tag i.e., I need "option 1" or anything based on selection. How can I do it. Kindly help. Thanks in advance :)










      share|improve this question














      I have select in my index page. It looks like below



      <div id="dropdown" class="input-group" style="width:50%">
      <select class="form-control" id="select2" name="select2" onchange="javascript:document.form1.submit();" style="width : 250px">
      <option value="C:/path1" >option 1/option>
      <option value="C:/path2" >option 2</option>
      <option value="C:/path3" >option 3</option>
      <option value="C:/path4" >option 4</option>
      <option value="C:/path5" >option 5</option>
      <option value="C:/path6" >option 6</option>
      </select>
      </div>


      I need value of "Value" attribute i.e., "C:/path1" which I'm able to fetch in Servlet using



      String value= request.getParameter("select2");


      Now I need to fetch text between tag i.e., I need "option 1" or anything based on selection. How can I do it. Kindly help. Thanks in advance :)







      jsp select servlets request html-select






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 22 at 5:42









      newbie 22newbie 22

      52




      52






















          2 Answers
          2






          active

          oldest

          votes


















          0














          With form you can only value of selected option if you want the option label as well then you need to write extra logic to send the data to server.



          <div id="dropdown" class="input-group" style="width:50%">
          <input type="hidden" name="selectedLabel" id="selectedLabel">
          <select class="form-control" id="select2" name="select2" onchange="javascript:getSelectedLabel(this);" style="width : 250px">
          <option value="C:/path1" >option 1/option>
          <option value="C:/path2" >option 2</option>
          <option value="C:/path3" >option 3</option>
          <option value="C:/path4" >option 4</option>
          <option value="C:/path5" >option 5</option>
          <option value="C:/path6" >option 6</option>
          </select>
          </div>


          JS: using this function you set the option label to hidden field and the hidden field will be sent along with your form data.



          function getSelectedLabel(sel) 
          document.getElementById("selectedLabel").value = sel.options[sel.selectedIndex].text;
          document.form1.submit();



          Server side:



          String value= request.getParameter("select2");
          String label = request.getParameter("selectedLabel");





          share|improve this answer

























          • Hi Srinu . I would like to get that value in Servlet not in js. Can you please help me how to fetch in servlet.

            – newbie 22
            Mar 22 at 6:21











          • @newbie22, by default html form will not send the option text to server. If you want the text then you need send it explicitly. In js I am setting the value to hidden variable so that the value will be available for server. In my code I added a hidden variable and setting value to it before form submission.

            – Srinu
            Mar 22 at 6:25











          • Thanks a lot @Srinu . I tried your code. I think this way is best. But when I print that hidden text value in servlet I'm getting null value

            – newbie 22
            Mar 22 at 6:27











          • the hidden field should inside form tag then only the value will sent to server. Also verify hidden field has id attribute or not, coz in js we are using document.getElementById set the value.

            – Srinu
            Mar 22 at 6:37











          • Yes @Srinu it is inside <form> tag and it has ID. But still when I try to fetch in servlet using String services = request.getParameter("selectedLabel"); I'm getting no value or empty string

            – newbie 22
            Mar 22 at 6:50


















          0














          here the simple and quick solution.



          Try this



          <select class="form-control" id="select2" name="select2" onchange="javascript:document.form1.submit();" style="width : 250px">
          <option value="C:/path1_option 1" >option 1/option>
          <option value="C:/path2_option 2" >option 2</option>
          </select>


          If your send the data to servlet like this (path + option text) the you can get the data by request.getParameter() method and split the data using java code.



          String value= request.getParameter("select2");
          String vals[] = value.split("_",0);

          for(String v : vals)
          System.out.println(v);



          so, you can get these two values....






          share|improve this answer























          • Nope...Still getting the value of "value" attribute

            – newbie 22
            Mar 22 at 6:05











          • you can get the value of path plus and option value right ? then whats the porblem ?

            – SandyKrish
            Mar 22 at 6:16











          • Nope. I'm getting just path value. I also tried String vals[] = value.split("_",1); It didnt work. If I select "Option1" I should get "option 1" not "C:/path1_option 1"

            – newbie 22
            Mar 22 at 6:19











          • I dont want to alter path value also...because I'm using it else where

            – newbie 22
            Mar 22 at 6:20











          • how you send the data with form ? can you send me the full code and can you able to get the value (path) in your code before ?

            – SandyKrish
            Mar 22 at 7:50












          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%2f55293528%2fhow-to-get-text-between-option-tag-in-servlet-option%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









          0














          With form you can only value of selected option if you want the option label as well then you need to write extra logic to send the data to server.



          <div id="dropdown" class="input-group" style="width:50%">
          <input type="hidden" name="selectedLabel" id="selectedLabel">
          <select class="form-control" id="select2" name="select2" onchange="javascript:getSelectedLabel(this);" style="width : 250px">
          <option value="C:/path1" >option 1/option>
          <option value="C:/path2" >option 2</option>
          <option value="C:/path3" >option 3</option>
          <option value="C:/path4" >option 4</option>
          <option value="C:/path5" >option 5</option>
          <option value="C:/path6" >option 6</option>
          </select>
          </div>


          JS: using this function you set the option label to hidden field and the hidden field will be sent along with your form data.



          function getSelectedLabel(sel) 
          document.getElementById("selectedLabel").value = sel.options[sel.selectedIndex].text;
          document.form1.submit();



          Server side:



          String value= request.getParameter("select2");
          String label = request.getParameter("selectedLabel");





          share|improve this answer

























          • Hi Srinu . I would like to get that value in Servlet not in js. Can you please help me how to fetch in servlet.

            – newbie 22
            Mar 22 at 6:21











          • @newbie22, by default html form will not send the option text to server. If you want the text then you need send it explicitly. In js I am setting the value to hidden variable so that the value will be available for server. In my code I added a hidden variable and setting value to it before form submission.

            – Srinu
            Mar 22 at 6:25











          • Thanks a lot @Srinu . I tried your code. I think this way is best. But when I print that hidden text value in servlet I'm getting null value

            – newbie 22
            Mar 22 at 6:27











          • the hidden field should inside form tag then only the value will sent to server. Also verify hidden field has id attribute or not, coz in js we are using document.getElementById set the value.

            – Srinu
            Mar 22 at 6:37











          • Yes @Srinu it is inside <form> tag and it has ID. But still when I try to fetch in servlet using String services = request.getParameter("selectedLabel"); I'm getting no value or empty string

            – newbie 22
            Mar 22 at 6:50















          0














          With form you can only value of selected option if you want the option label as well then you need to write extra logic to send the data to server.



          <div id="dropdown" class="input-group" style="width:50%">
          <input type="hidden" name="selectedLabel" id="selectedLabel">
          <select class="form-control" id="select2" name="select2" onchange="javascript:getSelectedLabel(this);" style="width : 250px">
          <option value="C:/path1" >option 1/option>
          <option value="C:/path2" >option 2</option>
          <option value="C:/path3" >option 3</option>
          <option value="C:/path4" >option 4</option>
          <option value="C:/path5" >option 5</option>
          <option value="C:/path6" >option 6</option>
          </select>
          </div>


          JS: using this function you set the option label to hidden field and the hidden field will be sent along with your form data.



          function getSelectedLabel(sel) 
          document.getElementById("selectedLabel").value = sel.options[sel.selectedIndex].text;
          document.form1.submit();



          Server side:



          String value= request.getParameter("select2");
          String label = request.getParameter("selectedLabel");





          share|improve this answer

























          • Hi Srinu . I would like to get that value in Servlet not in js. Can you please help me how to fetch in servlet.

            – newbie 22
            Mar 22 at 6:21











          • @newbie22, by default html form will not send the option text to server. If you want the text then you need send it explicitly. In js I am setting the value to hidden variable so that the value will be available for server. In my code I added a hidden variable and setting value to it before form submission.

            – Srinu
            Mar 22 at 6:25











          • Thanks a lot @Srinu . I tried your code. I think this way is best. But when I print that hidden text value in servlet I'm getting null value

            – newbie 22
            Mar 22 at 6:27











          • the hidden field should inside form tag then only the value will sent to server. Also verify hidden field has id attribute or not, coz in js we are using document.getElementById set the value.

            – Srinu
            Mar 22 at 6:37











          • Yes @Srinu it is inside <form> tag and it has ID. But still when I try to fetch in servlet using String services = request.getParameter("selectedLabel"); I'm getting no value or empty string

            – newbie 22
            Mar 22 at 6:50













          0












          0








          0







          With form you can only value of selected option if you want the option label as well then you need to write extra logic to send the data to server.



          <div id="dropdown" class="input-group" style="width:50%">
          <input type="hidden" name="selectedLabel" id="selectedLabel">
          <select class="form-control" id="select2" name="select2" onchange="javascript:getSelectedLabel(this);" style="width : 250px">
          <option value="C:/path1" >option 1/option>
          <option value="C:/path2" >option 2</option>
          <option value="C:/path3" >option 3</option>
          <option value="C:/path4" >option 4</option>
          <option value="C:/path5" >option 5</option>
          <option value="C:/path6" >option 6</option>
          </select>
          </div>


          JS: using this function you set the option label to hidden field and the hidden field will be sent along with your form data.



          function getSelectedLabel(sel) 
          document.getElementById("selectedLabel").value = sel.options[sel.selectedIndex].text;
          document.form1.submit();



          Server side:



          String value= request.getParameter("select2");
          String label = request.getParameter("selectedLabel");





          share|improve this answer















          With form you can only value of selected option if you want the option label as well then you need to write extra logic to send the data to server.



          <div id="dropdown" class="input-group" style="width:50%">
          <input type="hidden" name="selectedLabel" id="selectedLabel">
          <select class="form-control" id="select2" name="select2" onchange="javascript:getSelectedLabel(this);" style="width : 250px">
          <option value="C:/path1" >option 1/option>
          <option value="C:/path2" >option 2</option>
          <option value="C:/path3" >option 3</option>
          <option value="C:/path4" >option 4</option>
          <option value="C:/path5" >option 5</option>
          <option value="C:/path6" >option 6</option>
          </select>
          </div>


          JS: using this function you set the option label to hidden field and the hidden field will be sent along with your form data.



          function getSelectedLabel(sel) 
          document.getElementById("selectedLabel").value = sel.options[sel.selectedIndex].text;
          document.form1.submit();



          Server side:



          String value= request.getParameter("select2");
          String label = request.getParameter("selectedLabel");






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 22 at 6:25

























          answered Mar 22 at 6:19









          SrinuSrinu

          1,3711017




          1,3711017












          • Hi Srinu . I would like to get that value in Servlet not in js. Can you please help me how to fetch in servlet.

            – newbie 22
            Mar 22 at 6:21











          • @newbie22, by default html form will not send the option text to server. If you want the text then you need send it explicitly. In js I am setting the value to hidden variable so that the value will be available for server. In my code I added a hidden variable and setting value to it before form submission.

            – Srinu
            Mar 22 at 6:25











          • Thanks a lot @Srinu . I tried your code. I think this way is best. But when I print that hidden text value in servlet I'm getting null value

            – newbie 22
            Mar 22 at 6:27











          • the hidden field should inside form tag then only the value will sent to server. Also verify hidden field has id attribute or not, coz in js we are using document.getElementById set the value.

            – Srinu
            Mar 22 at 6:37











          • Yes @Srinu it is inside <form> tag and it has ID. But still when I try to fetch in servlet using String services = request.getParameter("selectedLabel"); I'm getting no value or empty string

            – newbie 22
            Mar 22 at 6:50

















          • Hi Srinu . I would like to get that value in Servlet not in js. Can you please help me how to fetch in servlet.

            – newbie 22
            Mar 22 at 6:21











          • @newbie22, by default html form will not send the option text to server. If you want the text then you need send it explicitly. In js I am setting the value to hidden variable so that the value will be available for server. In my code I added a hidden variable and setting value to it before form submission.

            – Srinu
            Mar 22 at 6:25











          • Thanks a lot @Srinu . I tried your code. I think this way is best. But when I print that hidden text value in servlet I'm getting null value

            – newbie 22
            Mar 22 at 6:27











          • the hidden field should inside form tag then only the value will sent to server. Also verify hidden field has id attribute or not, coz in js we are using document.getElementById set the value.

            – Srinu
            Mar 22 at 6:37











          • Yes @Srinu it is inside <form> tag and it has ID. But still when I try to fetch in servlet using String services = request.getParameter("selectedLabel"); I'm getting no value or empty string

            – newbie 22
            Mar 22 at 6:50
















          Hi Srinu . I would like to get that value in Servlet not in js. Can you please help me how to fetch in servlet.

          – newbie 22
          Mar 22 at 6:21





          Hi Srinu . I would like to get that value in Servlet not in js. Can you please help me how to fetch in servlet.

          – newbie 22
          Mar 22 at 6:21













          @newbie22, by default html form will not send the option text to server. If you want the text then you need send it explicitly. In js I am setting the value to hidden variable so that the value will be available for server. In my code I added a hidden variable and setting value to it before form submission.

          – Srinu
          Mar 22 at 6:25





          @newbie22, by default html form will not send the option text to server. If you want the text then you need send it explicitly. In js I am setting the value to hidden variable so that the value will be available for server. In my code I added a hidden variable and setting value to it before form submission.

          – Srinu
          Mar 22 at 6:25













          Thanks a lot @Srinu . I tried your code. I think this way is best. But when I print that hidden text value in servlet I'm getting null value

          – newbie 22
          Mar 22 at 6:27





          Thanks a lot @Srinu . I tried your code. I think this way is best. But when I print that hidden text value in servlet I'm getting null value

          – newbie 22
          Mar 22 at 6:27













          the hidden field should inside form tag then only the value will sent to server. Also verify hidden field has id attribute or not, coz in js we are using document.getElementById set the value.

          – Srinu
          Mar 22 at 6:37





          the hidden field should inside form tag then only the value will sent to server. Also verify hidden field has id attribute or not, coz in js we are using document.getElementById set the value.

          – Srinu
          Mar 22 at 6:37













          Yes @Srinu it is inside <form> tag and it has ID. But still when I try to fetch in servlet using String services = request.getParameter("selectedLabel"); I'm getting no value or empty string

          – newbie 22
          Mar 22 at 6:50





          Yes @Srinu it is inside <form> tag and it has ID. But still when I try to fetch in servlet using String services = request.getParameter("selectedLabel"); I'm getting no value or empty string

          – newbie 22
          Mar 22 at 6:50













          0














          here the simple and quick solution.



          Try this



          <select class="form-control" id="select2" name="select2" onchange="javascript:document.form1.submit();" style="width : 250px">
          <option value="C:/path1_option 1" >option 1/option>
          <option value="C:/path2_option 2" >option 2</option>
          </select>


          If your send the data to servlet like this (path + option text) the you can get the data by request.getParameter() method and split the data using java code.



          String value= request.getParameter("select2");
          String vals[] = value.split("_",0);

          for(String v : vals)
          System.out.println(v);



          so, you can get these two values....






          share|improve this answer























          • Nope...Still getting the value of "value" attribute

            – newbie 22
            Mar 22 at 6:05











          • you can get the value of path plus and option value right ? then whats the porblem ?

            – SandyKrish
            Mar 22 at 6:16











          • Nope. I'm getting just path value. I also tried String vals[] = value.split("_",1); It didnt work. If I select "Option1" I should get "option 1" not "C:/path1_option 1"

            – newbie 22
            Mar 22 at 6:19











          • I dont want to alter path value also...because I'm using it else where

            – newbie 22
            Mar 22 at 6:20











          • how you send the data with form ? can you send me the full code and can you able to get the value (path) in your code before ?

            – SandyKrish
            Mar 22 at 7:50
















          0














          here the simple and quick solution.



          Try this



          <select class="form-control" id="select2" name="select2" onchange="javascript:document.form1.submit();" style="width : 250px">
          <option value="C:/path1_option 1" >option 1/option>
          <option value="C:/path2_option 2" >option 2</option>
          </select>


          If your send the data to servlet like this (path + option text) the you can get the data by request.getParameter() method and split the data using java code.



          String value= request.getParameter("select2");
          String vals[] = value.split("_",0);

          for(String v : vals)
          System.out.println(v);



          so, you can get these two values....






          share|improve this answer























          • Nope...Still getting the value of "value" attribute

            – newbie 22
            Mar 22 at 6:05











          • you can get the value of path plus and option value right ? then whats the porblem ?

            – SandyKrish
            Mar 22 at 6:16











          • Nope. I'm getting just path value. I also tried String vals[] = value.split("_",1); It didnt work. If I select "Option1" I should get "option 1" not "C:/path1_option 1"

            – newbie 22
            Mar 22 at 6:19











          • I dont want to alter path value also...because I'm using it else where

            – newbie 22
            Mar 22 at 6:20











          • how you send the data with form ? can you send me the full code and can you able to get the value (path) in your code before ?

            – SandyKrish
            Mar 22 at 7:50














          0












          0








          0







          here the simple and quick solution.



          Try this



          <select class="form-control" id="select2" name="select2" onchange="javascript:document.form1.submit();" style="width : 250px">
          <option value="C:/path1_option 1" >option 1/option>
          <option value="C:/path2_option 2" >option 2</option>
          </select>


          If your send the data to servlet like this (path + option text) the you can get the data by request.getParameter() method and split the data using java code.



          String value= request.getParameter("select2");
          String vals[] = value.split("_",0);

          for(String v : vals)
          System.out.println(v);



          so, you can get these two values....






          share|improve this answer













          here the simple and quick solution.



          Try this



          <select class="form-control" id="select2" name="select2" onchange="javascript:document.form1.submit();" style="width : 250px">
          <option value="C:/path1_option 1" >option 1/option>
          <option value="C:/path2_option 2" >option 2</option>
          </select>


          If your send the data to servlet like this (path + option text) the you can get the data by request.getParameter() method and split the data using java code.



          String value= request.getParameter("select2");
          String vals[] = value.split("_",0);

          for(String v : vals)
          System.out.println(v);



          so, you can get these two values....







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 22 at 5:59









          SandyKrishSandyKrish

          235




          235












          • Nope...Still getting the value of "value" attribute

            – newbie 22
            Mar 22 at 6:05











          • you can get the value of path plus and option value right ? then whats the porblem ?

            – SandyKrish
            Mar 22 at 6:16











          • Nope. I'm getting just path value. I also tried String vals[] = value.split("_",1); It didnt work. If I select "Option1" I should get "option 1" not "C:/path1_option 1"

            – newbie 22
            Mar 22 at 6:19











          • I dont want to alter path value also...because I'm using it else where

            – newbie 22
            Mar 22 at 6:20











          • how you send the data with form ? can you send me the full code and can you able to get the value (path) in your code before ?

            – SandyKrish
            Mar 22 at 7:50


















          • Nope...Still getting the value of "value" attribute

            – newbie 22
            Mar 22 at 6:05











          • you can get the value of path plus and option value right ? then whats the porblem ?

            – SandyKrish
            Mar 22 at 6:16











          • Nope. I'm getting just path value. I also tried String vals[] = value.split("_",1); It didnt work. If I select "Option1" I should get "option 1" not "C:/path1_option 1"

            – newbie 22
            Mar 22 at 6:19











          • I dont want to alter path value also...because I'm using it else where

            – newbie 22
            Mar 22 at 6:20











          • how you send the data with form ? can you send me the full code and can you able to get the value (path) in your code before ?

            – SandyKrish
            Mar 22 at 7:50

















          Nope...Still getting the value of "value" attribute

          – newbie 22
          Mar 22 at 6:05





          Nope...Still getting the value of "value" attribute

          – newbie 22
          Mar 22 at 6:05













          you can get the value of path plus and option value right ? then whats the porblem ?

          – SandyKrish
          Mar 22 at 6:16





          you can get the value of path plus and option value right ? then whats the porblem ?

          – SandyKrish
          Mar 22 at 6:16













          Nope. I'm getting just path value. I also tried String vals[] = value.split("_",1); It didnt work. If I select "Option1" I should get "option 1" not "C:/path1_option 1"

          – newbie 22
          Mar 22 at 6:19





          Nope. I'm getting just path value. I also tried String vals[] = value.split("_",1); It didnt work. If I select "Option1" I should get "option 1" not "C:/path1_option 1"

          – newbie 22
          Mar 22 at 6:19













          I dont want to alter path value also...because I'm using it else where

          – newbie 22
          Mar 22 at 6:20





          I dont want to alter path value also...because I'm using it else where

          – newbie 22
          Mar 22 at 6:20













          how you send the data with form ? can you send me the full code and can you able to get the value (path) in your code before ?

          – SandyKrish
          Mar 22 at 7:50






          how you send the data with form ? can you send me the full code and can you able to get the value (path) in your code before ?

          – SandyKrish
          Mar 22 at 7:50


















          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%2f55293528%2fhow-to-get-text-between-option-tag-in-servlet-option%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







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript