Get total from string valve

hi , I have some like
String quesFour=req.getParameter("quesFour");
String quesFive=req.getParameter("quesFive");
String quesSix=req.getParameter("quesSix");
String quesSeven=req.getParameter("quesSeven");
String quesEight=req.getParameter("quesEight");
String quesNine=req.getParameter("quesNine");
String quesTen=req.getParameter("quesTen");
String quesEleven=req.getParameter("quesEleven");
every question in form have radio relate to it
<table ><tr><td width="30px"> <input type="radio" name="quesTwo" value="0">0</td>
                                                  <td width="30px">   </td>
                                                  <td width="40px"><input type="radio" name="quesTwo" value="1">1</td>
                                                     <td>   </td>
                                                      <td colspan="3" width="50px"><input type="radio" name="quesTwo" value="2">2</td>                                                       
                                                        <td>   </td>                                                        
                                                         <td colspan="3" width="50px"><input type="radio" name="quesTwo" value="3">3</td>     
                                              </tr></table> after the user submit a form , I want to get totaly point they have, how to do it? thak you

HJava wrote:
hi , I have some like
String quesFour=req.getParameter("quesFour");
String quesFive=req.getParameter("quesFive");
String quesSix=req.getParameter("quesSix");
String quesSeven=req.getParameter("quesSeven");
String quesEight=req.getParameter("quesEight");
String quesNine=req.getParameter("quesNine");
String quesTen=req.getParameter("quesTen");
String quesEleven=req.getParameter("quesEleven");
Integer.parseInt(String value)If you want to make this more "dynamic" then you could have an array of questions and have form elements named things like
<radio name="q_0"
<radio name="q_1"etc and then in your code have
for(int i=0,i<something;i++){
  req.getParameter("q_"+i);
}

Similar Messages

  • Get chars from string of numerals

    here is what I would like to accomplish:
    Put the last four integers of the systemDate into a variable so I can do some math with them.
    Thanks.

    Excellent.  Thank you for the info.  Very helpful.
    Dewey
    From: jchunick [email protected]
    Sent: Friday, June 03, 2011 4:20 PM
    To: Dewey Parker
    Subject: Re: get chars from string of numerals
    This is a post I made for the wiki which should help: http://director-online.com/dougwiki/index.php?title=Undocumented_Lingo#the_systemDate

  • How to get substring from string starting from the end of string

    Hi
    How to cut from string:
    $A=C:\ClusterStorage\Volume1\WXP-plwropc300\Virtual Hard Disks\WXP-PLWROPC300_EE20E00F-315E-4781-A6DE-68497D4189B8.avhdx
    this substring (name of VHD file): WXP-PLWROPC300_EE20E00F-315E-4781-A6DE-68497D4189B8.avhdx
    This script should be universal so the best way to be cut all leters from the end of string $A till get the first mark \
    Thank you for help.
    Tomasz
    Kind Regards Tomasz

    PS > Split-Path 'C:\ClusterStorage\Volume1\WXP-plwropc300\Virtual Hard Disks\WXP-PLWROPC300_EE20E00F-315E-4781
    -A6DE-68497D4189B8.avhdx' -leaf
    WXP-PLWROPC300_EE20E00F-315E-4781-A6DE-68497D4189B8.avhdx
    PS >
    That is what "Split-Path" is for:
    ¯\_(ツ)_/¯

  • How to get InputStream from String ?

    Hi !
    I want to get InputStream object from String.
    String str = "balabalabala";
    InputStream stream = getInputStream(str);
    How to realize getInputStream(str) function ?
    Thanks!

    The preferred method nowadays is to use Readers and Writers for String data - hence StringReader(String). If you're going to operate on the InputStream directly, then I'd modify your code to use the Reader calls and go that route.
    If, however, you need to pass the InputStream to some other piece of API that requires an InputStream instead of a Reader, then the ByteArrayInputStream is probably your best bet. StringBufferInputStream is deprecated because it doesn't work reliably in the face of many character encodings.
    Speaking of encodings - never call Strng.getBytes() - always use the getBytes(character-encoding) version, so you KNOW what encoding you're getting!
    Grant

  • Get Items from String

    VB.net
    I need to get the third and forth item from a string. The string varies in items within delimiter and total number of delimiters.
    My delimiter is :
    MyString = "ALL:0:Red:11Green:31:Blue:217"
    MyItems = "Red:11"
    Also, if elements 3 and 4 are not there, messagebox.show("Items don't exist.")
    Thanks,
    ADawn
    ADawn

    There is a : between 11 and Green.
    "ALL:0:Red:11:Green:31:Blue:217"
    ADawn
    ADawn
    Then it's even easier.
    Option Strict On
    Option Explicit On
    Option Infer Off
    Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim s As String = "ALL:0:Red:11:Green:31:Blue:217"
    Dim parts As List(Of String) = s.Split(":"c).ToList
    Dim allLabel As String = parts(0)
    Dim allValue As String = parts(1)
    Dim redLabel As String = parts(2)
    Dim redValue As String = parts(3)
    Dim greenLabel As String = parts(4)
    Dim greenValue As String = parts(5)
    Dim blueLabel As String = parts(6)
    Dim blueValue As String = parts(7)
    MsgBox(String.Format("{0}:{1}", redLabel, redValue))
    End Sub
    End Class
    “If you want something you've never had, you need to do something you've never done.”
    Don't forget to mark
    helpful posts and answers
    ! Answer an interesting question? Write a
    new article
    about it! My Articles
    *This post does not reflect the opinion of Microsoft, or its employees.

  • How to get substring from string using index?

    hi,
    here i am having string ,
    i want the pullareddy from below line ,
    i know how to get from substring.
    but i want to get the above using "index",
    can any help how to do it?
    String str1="janapana,pullareddy, in malaysia";
    jpullareddy

    get the start index with indexAt("pullareddy")
    get the end index with adding the length of the word to the start
    get the char[] of str1 with toCharArray()
    make a new string with the chars from start to end index.

  • Help on getting value from string

    Hello can someone please help me with my code?
    I would like to know how to get a value in a string as an integer type
    This is what I have so far
    String x = "12345";
    for(int f=0; f<5; f++){
    int c = stringDigits.charAt(f);     
    sum += c;                
    However the sum does not turn out to be 1+2+3+4+5 = 15 because the value of c will always turn out to be 48 more than it is supposed to be
    for example when f = 1 then c would = 49
    f = 2 then c would = 51
    Thank you very much for your help

    int i = Integer.parseInt(x);
    Will convert the String to an integer.The original poster was looking for a way to convert a single digit in a string to its numeric value, not to convert the whole string to an integer.
    I forgot to mention that this is contained in the
    java.text package, so you will need to
    import java.text.*;Integer is in the java.lang package, so no import is necessary.

  • Can we get Arraylist from String.Please check the code

    Hi all,
    I have just pasted my code over here.Can anyone of you find the solution for obtaining the Array list from the String.
    For Example :
    ArrayList al = new ArrayList();
    al.add(new byte[2]);
    al.add("2");
    String stringVar = "" + (ArrayList) al;
    Here I can convert the arraylist into string.But can we do he vice versa like obtaining the above arraylist from the string?If please advice me.
    URGENT!!!!

    cudIf you run the code you posted you will observe that the string form of the list does not contain all the information of the list: in particular the array elements are missing. It follows that the "vice versa" conversion you seek is simply not possible.
    A variation on this theme is the following:import java.util.ArrayList;
    public class ListEg {
        public static void main(String[] args) {
            ArrayList al = new ArrayList();
            al.add("foo");
            al.add("bar, baz");
            String stringVar = "" + (ArrayList) al;     
            System.out.println(stringVar);
    }If you think about the output you should be able to conclude that lists with different contents can easily have the same string form.
    Just something to chew on.

  • Get path from string in an column

    I have an data with text and url. I need to seprate the url only in the column and display in sql query
    Need to get data after Url: and the next immediate " " {blank space}
    my data is like below
    seach engine Url: www.bing.com this is the world famous search enging
    mail box Url: www.hotmail.com email is free
    microsoft webstie Url: http:\\microsoft.com the home page of microsoft.
    ShanmugaRaj

    Try the below:
    Create table Test_Shan(Textstring Varchar(1000))
    Insert into Test_Shan Values ('seach engine Url: www.bing.com this is the world famous search enging'),
    ('mail box Url: www.hotmail.com email is free'),
    ('microsoft webstie Url: http:\\microsoft.com the home page of microsoft.')
    Select substring(LTRIM(stuff(Textstring,1,CHARINDEX('Url:',Textstring)+4,' ')),0,charindex(' ',LTRIM(stuff(Textstring,1,CHARINDEX('Url: ',Textstring)+4,' ')),0))
    From Test_Shan

  • How to get recors from String

    I have a String contains records seperated by tab.How cani break up into individual record and get them
    Bill Mor     1234     US-TEXAS     56
    John Cruz     4567     UK-EDH     45
    I need
    Bill Mor
    1234
    US-TEXAS
    56
    then
    John Cruz
    4567
    UK-EDH
    45

    String[] splitLine = line.split("\t");

  • Get data from string

    My Table Column have below data
    COLUMN A
    Name of my Country is India
    I am from Country Japan
    My Country is China
    How to get result as below
    "Country is India"
    "Country Japan"
    "Country is China"
    ShanmugaRaj

    Try:
    DECLARE @t TABLE (Info VARCHAR(300));
    INSERT INTO @t (Info)
    VALUES ('Name of my Country is India')
    ,('I am from Country Japan')
    ,('My Country is China')
    ,('Testing');
    SELECT Info
    ,substring(Info, NULLIF(charindex('Country', Info), 0), LEN(Info)) AS [Country Info]
    FROM @t;
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Get number from string

    Hi,
    I have a problem with an select.
    I need to compare two string columns. First column includes only a number with 9 characters:
    '001234567'
    Second column includes text where somewhere inside this text is the number 001234567.
    'Hallo1 001234567'
    I need to extract the 9 character big number out of the string. I thought using the regular expression feature could help me.
    SELECT
      REPLACE(REGEXP_REPLACE('hallo 001122334', '[a-z]', ''),' ') "REGEXP_REPLACE"
    FROM dual;But this would exclude the number 1 after Hallo:
    Result: '1001234567'
    The number I look for is always 9 character long.
    Thanks ahead,
    Tobias

    You have many variants:
    with your_table as
         (select
                'hallo1001122334' first_column,
                '001122334' second_column
          from dual
    select *
    from your_table
    where
    --1) regexp_like(first_column,'.*'||second_column||'$')
    --2) first_column like '%'||second_column
    --3) regexp_substr(first_column,'\d{9}$')=second_column
    --4) regexp_replace(first_column,'\D','') like '%'||second_columnFourth variant - includes case when chars can be between numbers in first column (for example 'hallo100a1a1a2a2a3a3a4').

  • Regular expression to get substring from string

    Hi,
    I’m having the following problem:
    SELECT REGEXP_SUBSTR(';first field;ir-second field-02;ir-second field-01; third field','.*ir-(.*)-01.*’)FROM dual
    [\CODE]
    This is the select that I have with a java expression!
    In java I’m able to do find the right expression to retrieve what I want, but I don’t know how to adapt this for oracle!
      In oracle I was trying to do something like this:
    NVL(SUBSTR(REGEXP_SUBSTR(CONCAT(';', list),';ir-[^01;]+'),LENGTH(';ir-')+1,LENGTH(REGEXP_SUBSTR(CONCAT(';',list),';ir-[^01;]+'))), ' ') AS result
    [\CODE]
    But it doesn’t work because “ir” can repeat in other parameters.
    “ir-something-01” only appears once.
    Is it in oracle a logic similar to result groups in oracle?
    best regards,
    Ricardo Tomás

    rctomas wrote:
    Hi,
    In java I’m able to do find the right expression to retrieve what I wantWell, would be nice to tell us what that right expression would be :). Anyway, is this what you are looking for:
    SQL> SELECT REGEXP_SUBSTR(';first field;ir-second field-02;ir-second field-01; third field',';ir-([^;]*)-01')
      2  from dual
      3  /
    REGEXP_SUBSTR(';FIR
    ;ir-second field-01
    SQL> SY.

  • Whats happening internally within the unflatten from string function?

    I am getting unflatten from string error intermitently in my program. I can't post the program to get help but essentially I am storing a GOOP object reference as a string. The reference is flattened to a string and stored upon creation, at a latter time the string is then unflatterned to retrieve the reference and then the data. This works most of the time but occansionaly the unflatterned from string function fails. Prior to passing the string to the function I am checking that the string isn't null. I am assuming something else is corrupting the string prior to passing to this fucntion and would like to know what would trigger the error in the function as it may help me realise what is happening
    prior.
    Cheers,
    Wayne

    Hi,
    It really seems strange this problem, but one thing that might be the cause is how you store the flatten string. You do not mention that. I have once had problems when storing GOOP references as a sting and passing them between test VIs in TestStand using a string parameters in TestStand. A flatten string might have special chars that not all applications (such as TestStand parameters) can handle that and just trunkate the string when such a char is present, mistakenly inteprets that as end of string. Have you tried to check that string length is the same?
    However to make sure you get rid of all problems with string termination, you really should cast your GOOP reference into something else. I would instead cast the reference to an U32, or
    if you want, to solve the string problem for other types than GOOP reference, then flatten the type into string and then convert the string to an array of U8 before storing it. This would by sure solve your problem.
    Regards,
    Mattias Ericsson
    Endevo
    Sweden
    Main developer of the new GOOP2 and GOOP Wizard 3.
    PS! Have you seen that there is a new GOOP release that also may handle inheritance? Please check out: http://www.endevo.se/default.asp?lang=eng and click on "Products". There are examples, demos and white papers describing the new GOOP Inheritance Toolkit.
    Attachments:
    CastRefExample.vi ‏18 KB

  • How to get an XML string from a Java Bean without wrting to a file first ?

    I know we can save a Java Bean to an XML file with XMLEncoder and then read it back with XMLDecoder.
    But how can I get an XML string of a Java Bean without writing to a file first ?
    For instance :
    My_Class A_Class = new My_Class("a",1,2,"Z", ...);
    String XML_String_Of_The_Class = an XML representation of A_Class ?
    Of course I can save it to a file with XMLEncoder, and read it in using XMLDecoder, then delete the file, I wonder if it is possible to skip all that and get the XML string directly ?
    Frank

    I think so too, but I am trying to send the object to a servlet as shown below, since I don't know how to send an object to a servlet, I can only turn it into a string and reconstruct it back to an object on the server side after receiving it :
    import java.io.*;
    import java.net.*;
    import java.util.*;
    class Servlet_Message        // Send a message to an HTTP servlet. The protocol is a GET or POST request with a URLEncoded string holding the arguments sent as name=value pairs.
      public static int GET=0;
      public static int POST=1;
      private URL servlet;
      // the URL of the servlet to send messages to
      public Servlet_Message(URL servlet) { this.servlet=servlet; }
      public String sendMessage(Properties args) throws IOException { return sendMessage(args,POST); }
      // Send the request. Return the input stream with the response if the request succeeds.
      // @param args the arguments to send to the servlet
      // @param method GET or POST
      // @exception IOException if error sending request
      // @return the response from the servlet to this message
      public String sendMessage(Properties args,int method) throws IOException
        String Input_Line;
        StringBuffer Result_Buf=new StringBuffer();
        // Set this up any way you want -- POST can be used for all calls, but request headers
        // cannot be set in JDK 1.0.2 so the query string still must be used to pass arguments.
        if (method==GET)
          URL url=new URL(servlet.toExternalForm()+"?"+toEncodedString(args));
          BufferedReader in=new BufferedReader(new InputStreamReader(url.openStream()));
          while ((Input_Line=in.readLine()) != null) Result_Buf.append(Input_Line+"\n");
        else     
          URLConnection conn=servlet.openConnection();
          conn.setDoInput(true);
          conn.setDoOutput(true);           
          conn.setUseCaches(false);
          // Work around a Netscape bug
          conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
          // POST the request data (html form encoded)
          DataOutputStream out=new DataOutputStream(conn.getOutputStream());
          if (args!=null && args.size()>0)
            out.writeBytes(toEncodedString(args));
    //        System.out.println("ServletMessage args: "+args);
    //        System.out.println("ServletMessage toEncString args: "+toEncodedString(args));     
          BufferedReader in=new BufferedReader(new InputStreamReader(conn.getInputStream()));
          while ((Input_Line=in.readLine()) != null) Result_Buf.append(Input_Line+"\n");
          out.flush();
          out.close(); // ESSENTIAL for this to work!          
        return Result_Buf.toString();               // Read the POST response data   
      // Encode the arguments in the property set as a URL-encoded string. Multiple name=value pairs are separated by ampersands.
      // @return the URLEncoded string with name=value pairs
      public String toEncodedString(Properties args)
        StringBuffer sb=new StringBuffer();
        if (args!=null)
          String sep="";
          Enumeration names=args.propertyNames();
          while (names.hasMoreElements())
            String name=(String)names.nextElement();
            try { sb.append(sep+URLEncoder.encode(name,"UTF-8")+"="+URLEncoder.encode(args.getProperty(name),"UTF-8")); }
    //        try { sb.append(sep+URLEncoder.encode(name,"UTF-16")+"="+URLEncoder.encode(args.getProperty(name),"UTF-16")); }
            catch (UnsupportedEncodingException e) { System.out.println(e); }
            sep="&";
        return sb.toString();
    }As shown above the servlet need to encode a string.
    Now my question becomes :
    <1> Is it possible to send an object to a servlet, if so how ? And at the receiving end how to get it back to an object ?
    <2> If it can't be done, how can I be sure to encode the string in the right format to send it over to the servlet ?
    Frank

Maybe you are looking for