Checking Value passed by Checkbox in a jsp page ??

hi all,
in my jsp page, i've a checkbox on a page & after submitting that page to another one, i want to check whether the checkbox was clicked or not..since in my code i wanna something like this...
if checkbox is clicked
//task1
else
{//task2
Can anyone please help me how to go 'bout it !

Hi ! romit
As the solns suggested above r correcti just wanna add another thing of ur interest ie when the checkbox is checked ,the url contains the thecked checkbox name equals "on"...i hope u understood what i meant...
ie
<input type=checkbox name="checkIt">
now in url...it will be like....
http://localhost/...../..... ..?...&check=on&.....
in case the checkbox is checked...else null value is passed....

Similar Messages

  • How to get value from a checkbox in a jsp page?

    hi there
    i have a form in a jsp which contains a <input type='checkbox' name='xx'>
    when i submit the form, how can i get the value for this checkbox? i could use request object to get parameter. i tried the following and could not get any value:
    request.getParameter("xx");
    is there any to get it? thanks.

    "checkbox" can have multiple values b/c you can check more than 1 checkbox and they can have same name.
    Example
    <input type="checkbox" name="number" value="1">one
    <input type="checkbox" name="number" value="2">two
    <input type="checkbox" name="number" value="3">three
    To get values of "number" field:
    String [] numberValues = request.getParameterValues("number");
    where numberValues[0] is the 1st value checked, numberValues[1] is 2nd value checkted and so on.....
    If you have no checkbox checked then you might get a "null pointer exception", so make sure you check to see if it's null first before accessing your numberValues array.
    If you just have 1 checkbox; then you can just call request.getParameterValue("number") and that will return your value.

  • How to use value returned from a bean in jsp page

    Hi All,
    I have a string array value being returned from a javabean to a jsp page. I want to be able to assign the value to a variable in the jsp page.
    How do I do this?
    Many thanks :)

    thanks for your response.
    I actually used something like this:
    <% String loggedin = log.User(user,password);
    out.println(loggedin);
    %>i am not yet as much of an expert on beans as i would like to be, but i thought it is not really a bean if it has a getter method which takes arguments?

  • Checkbox on a JSP page

    hi experts
    is there any control for Boolean field in JSP??
    how can bind boolean field in JSP page??
    waiting for help
    Thanks

    Surely, someone must have tried to put a checkbox on a JSP page and bind it to data?
    All suggestions are welcome.
    tnx
    -Jan

  • Passing values at run time through a JSP page to selection formula to crystal report

    <p>hi,</p><p>   i am using one jsp page.in that page there is a field to select a date </p><p>this value will go to the report and report contain one selection formula.</p><p>which value we are passing on that basis the report should display</p><p>with date which we are passing  from GUI.</p><p>help.............................................................</p><p>//R</p>

    I believe the value of this is based on the owner of the scheduled object.  So if the Admin is scheduling it on behalf of a user I think it should use the user the Admin scheduled on behalf of.  It should be simple to test, simply create a report with this value being displayed and nothing else and see what values you get.

  • Retrieve values from a table of a JSP page in Servlet.

    Hello all,
    I am new in JSP servlet world, I want to create a grid on JSP page using Servlet.
    Suppose i have some records in a JSP page and This JSP page will display these records in a tabular form. And, on a button click that table data should be
    accessible in servlet,
    Now, How can i traverse among all the rows of that table of JSP page in servlet. or How can i retrieve a specific cell record of that table of JSP page in servlet.
    Can anyone please answer this.
    Thank you and regards.

    Hi,
    Create in your HTML form inputs with the same name i.e.:
    <input name="a[]" value="2" >
    <input name="a[]" value="9" >
    In your jsp page use :
    String Values[] = request.getParameterValues("a[]") ;
    This will give you a string array of two elements.
    for (int x = 0; x < Values.length; x++)
        System.out.println(Values[x]) ;
    }Will print :
    2
    9
    Hope this helps.
    Bill Moo

  • Pass Object Between Applet and JSP Page

    Hi all,
    How can I pass an Object(such as Vector, File), rather than just string to the Applet from a JSP page?
    Thank you.

    I used Base64Encoder and Base64Decoder from servlets.com utilities.
    * convert any serializable object to a String
    public synchronized static String objectToString(Serializable obj) throws Exception {
        ByteArrayOutputStream bos = new ByteArrayOutputStream(100);
        ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(obj);
        byte[]bytes = bos.toByteArray();
        bos = new ByteArrayOutputStream(); //to save the encoded String
        Base64Encoder enc = new Base64Encoder(bos);
        enc.write(bytes);
        String encodedString = bos.toString();
        //close all
        enc.close();   
        oos.close();
        bos.close();
        return encodedString;
    * Recreates the object from the encoded String
    public synchronized static Object stringToObject(String str) throws Exception {
        ByteArrayInputStream bis = new ByteArrayInputStream(str.getBytes());
        Base64Decoder dec = new Base64Decoder(bis);
        ObjectInputStream ois = new ObjectInputStream(dec);
        Object obj = (Object)ois.readObject();
        ois.close();
        dec.close();
        bis.close();
        return obj;
    }

  • Pass bean property name across JSP pages

    First, the sample code:
    <%-- ================ some.jsp =============== --%>
    <%-- bunch of code [...] --%>
    <tr>
    <td><bean:message key="prompt.desc" /></td>
    <td><html:textarea property="desc" /></td>
    </tr>
    <tr>
    <td>
    <bean:message key="prompt.notes" />
    <tiles:insert page="checkSpellTile.jsp" flush="false"></tiles:insert>
    </td>
    </tr>
    <tr>
    <td><html:textarea property="notes" /></td>
    </tr>
    <%-- ================ end some.jsp =============== --%>
    <%-- ================ checkSpellTile.jsp =============== --%>
    <%-- some JSP code [...] --%>
    <spellingComp:executeSpelling
    mode="popup"
    textComponentName="notes"
    />
    <%-- ================ end checkSpellTile.jsp =============== --%>
    So, my first foray into JSP programming - I have a number of
    different JSP pages that need spell check widgets associated
    to some text fields. The sample code shown works fine. The
    prompt, "Notes ...:" is following by the spell check
    [clickable] widget. Then the user clicks the widget, the
    spell check is launched and it checks the text in the
    "notes" field for the form.
    The sticky situation that I can't seem to solve is that each
    of the forms associated with each of the different JSP pages
    has a different name for the text field (that needs to be
    spell checked).
    I've tried doing this (between the <tiles:insert...></tiles:insert...>):
    <tiles:put name="theNotes" beanName="orderForm" beanProperty="notes"/>
    ... and then in the checkSpellTile.jsp, inserting this:
    <tiles:importAttribute name="theNotes"/>
    ... and then for the "textComponentName" attribute:
    textComponentName="theNotes"
    Any ideas how do solve this problem?

    First, the sample code:
    <%-- ================ some.jsp =============== --%>
    <%-- bunch of code [...] --%>
    <tr>
    <td><bean:message key="prompt.desc" /></td>
    <td><html:textarea property="desc" /></td>
    </tr>
    <tr>
    <td>
    <bean:message key="prompt.notes" />
    <tiles:insert page="checkSpellTile.jsp" flush="false"></tiles:insert>
    </td>
    </tr>
    <tr>
    <td><html:textarea property="notes" /></td>
    </tr>
    <%-- ================ end some.jsp =============== --%>
    <%-- ================ checkSpellTile.jsp =============== --%>
    <%-- some JSP code [...] --%>
    <spellingComp:executeSpelling
    mode="popup"
    textComponentName="notes"
    />
    <%-- ================ end checkSpellTile.jsp =============== --%>
    So, my first foray into JSP programming - I have a number of
    different JSP pages that need spell check widgets associated
    to some text fields. The sample code shown works fine. The
    prompt, "Notes ...:" is following by the spell check
    [clickable] widget. Then the user clicks the widget, the
    spell check is launched and it checks the text in the
    "notes" field for the form.
    The sticky situation that I can't seem to solve is that each
    of the forms associated with each of the different JSP pages
    has a different name for the text field (that needs to be
    spell checked).
    I've tried doing this (between the <tiles:insert...></tiles:insert...>):
    <tiles:put name="theNotes" beanName="orderForm" beanProperty="notes"/>
    ... and then in the checkSpellTile.jsp, inserting this:
    <tiles:importAttribute name="theNotes"/>
    ... and then for the "textComponentName" attribute:
    textComponentName="theNotes"
    Any ideas how do solve this problem?

  • Passing jsf parameters to a jsp page

    how to access the parameters declared in jsf page from a jsp page.
    in the jsp page I need to access the paramaters something like request.getParameter("age");
    how to declare the same in the jsf page in h form.
    <h:form>
    <h:inputText value="" id = "age" />
    </h:form>
    and in the jsp page i should access this parameter like request.getParameter("age");
    how to accomplish this.
    Please help.

    Please don't doublepost. Continue here: http://forum.java.sun.com/thread.jspa?threadID=5252759

  • Updating value of a variable on a JSP page

    Hya!
    I am very new to JSP and I am struggling to make a homepage work according to the specifications my group has decided to use. I would be grateful if you could help me in this, as it's really urgent. Let me describe the issue:
    My web site contains a set of six JavaBeans that keep information that is more a less unchangeable (it works as a table). The information that is kept by the JavaBeans can be viewed by the user once he/she makes a selection. This information then will help the user in deciding to buy a certain number of tickets. That's the point where the problem appears.
    I need the variable 'totalTickets' to vary depending on each user's purchase. I've set the original value to 100 on JavaScript but that means that in each visit this number would be reset to 100 again, as JavaScript is a client-side technology. On the other hand if I set this variable in JSP the same problem would happen. Would there be a way to allow this variable to be reset after each visit? What would I need to make this possible?
    I am looking forward to hearing from all of you.
    Yours sincerely,
    Saulo

    Is this correct,
    1. User login to the system for the first time. Then TotalTicket count will be set to 100.
    2. User purchase a ticket and the count will become one less (i.e 99).
    3. For every purchase of a ticket, count will be reduced by one.
    4. User logs out. Now let us say, the count is 95. (i.e user has purchased 5 tickets).
    5. Now again user login to the syatem. The ticket count must be initialized to 95.
    and so on.
    If this is what you want, then you must either store the TicketCount in the database or atleast in the application context.
    int totalTicket=100;
    Hashtable ticketCounterMap=(Hashtable)application.getAttribute("ticketCounterMap")
    if(ticketCounterMap == null)
         ticketCounterMap = new Hashtable();
         ticketCounterMap.add("login_user_name",new Integer(totalTicket));
         application.setAttribute("ticketCounterMap");
    else
         totalTicket = ((Integer)ticketCounterMap.get("login_user_name")).intValue();
    and in case of purchasings.
    if(purchase.....)
         totalTicket--;
         ticketCounterMap.add("login_user_name",new Integer(totalTicket));
         application.setAttribute("ticketCounterMap");
    Hope this helps.
    Sudha
    P.S:- There may be errors in the above code. This is just to give you an idea.

  • Passing an array from one jsp page to another.

    I need to pass an array from one page to another, without using the query string.
    Can anyone help?
    I was given one suggestion about putting the array inside a Map object, then putting the map in the session.
    Is there an alternative? i am struggling to find out how to use maps properly.
    Alternatively, could someone give me a pointer on how to implement this possibility?
    Help needed ASAP.
    Thankyou

    First.jsp
    String[] str = {1,2,3,4,5};
    session = request.getSession(true);
    session.setAttribute("str",str); //or application.setAttribute("str",str);
    Second.jsp
    session = request.getSession();
    String str[] = (String[])session.getAttribute("str"); //or String str[] = (String[]) application.getAttribute("str");
    Now you can use str[].
    Sudha

  • How can we pass selected combo box value to a jsp pag?

    Hi All,
    I want to pass selected combo box value to a same jsp page's variable.
    i am using javascript
    <select onchange="this.options[this.selectedIndex].text">
    </select>
    this selected value should be invoked for a jsp page's variable.
    Excepting for favorable reply
    Vansh

    select2.jsp
    <script>
    function x()
         alert(document.f.s.options[document.f.s.selectedIndex].text);
         document.f.submit();
    </script>
    <body>
    <form method="get" name="f" action="select2.jsp">
    <select name="s" onchange="x()">
    <option checked>--select--</option>
    <option value="1"> vijay </option>
    <option value="2"> kumar </option>
    </select>
    </form>
    </body>

  • Additional CheckBoxes on JSP Page

    Dear All,
    I have created 10 Additional CheckBoxes on a JSP Page in Apps through pesonalization by Create Item option and chosen (MessageStylesCheckBox).
    The Value of this CheckBox is 1 if it is checked and 0 if it is unchecked. Now I want to track these two values. Are these checkboxes have any
    impact on the underlying table or where this information goes? Do I have to put anything inside View Attribute and View Instance?
    Please help if anybody knows this.
    Regards

    Try to check the settings for the section and the column, maybe you have one chance there to hide it. As you can now "freeze" one column and scroll another one that scroll bar is the one of the column (I guess), if you click to display all result the scroll will happen on the "inner" scroll, not the one of page (the one on the right), as far as I remember.
    Now sure it's a problem, it's more the normal way to support advanced behavior in a dashboard with multiple columns / sections.

  • Display values from database in jsp page

    Hi,
    I need to display a list of options with checkboxes in a jsp page .The values are retrived from DB.
    formBean fb=new FormBean(request)
    <Input type="checkbox" name="xyz" value="<%=fb.getFormdata( "xyz")%>">
    should this"xyz" be the name of the column in the DB table?

    This is my FormBean
    public class FormBean {
    HttpServletRequest _request;
    public FormBean(HttpServletRequest request) {
    _request = request;
    public String getFormData(String abc) {
    return getFormData(abc, true);
    public String getFormData(String name, boolean filter) {
    String value = null;
    if (_request != null) {
    value = _request.getParameter(abc);
    if (value == null) value = "";
    if (filter) {
    value = Utils.filter(value);
    return value;
    * "Clears" parameters. Useful if you do wnat a form initialized with blanks rather than
    * current values;
    public void clear() {
    _request = null;
    }

  • Problem in passing data from one .jsp page to another .jsp page

    i have a problem here
    Actually i have 2 jsp pages. What im trying to do here is actually i want to pass data from the first jsp page to the second for updating
    The first jsp page contains data that user wants to update in the form of table.
    <td><img src = "edit.gif" alt = "edit" border="0" ><td>
    <TD><%= Name %></td>
    <TD><%= rs.getInt("Age") %></td>
    <TD><%= rs.getString("Gender") %></td>
    So this page displays the data that users wants to update plus one image button (edit button). So when user clicks this button, all the data in this page will be brought to the second .jsp page called updatePersonal for updating.
    The problem here is that it is not displaying the existing data in the second .jsp page.
    The second page basically contains forms
    <INPUT TYPE="text" NAME="FirstName" maxlength="30" value = "<%=FirstName%>">
    Can someone please help me. I really dont know what to do..How do i get the data displayed in the text field that is passed from the first .jsp page..thankx in advance

    Please modify below code to:
    td><img src = "edit.gif" alt = "edit" border="0" ><td>
    -----------------modified code
    td><a href="updatePersonal.jsp?FirstName=<%=rs.getString(FirstName")%">&LastName=<%=rs.getString("LastName")%>&Age=<%=rs.getInt("Age")%>&Gender=<%=rs.getString("Gender")%>"><img src = "edit.gif" alt = "edit" border="0" ></a><td>
    I'm sure it works</a>

Maybe you are looking for

  • Re-partitioning and re-installing Windows XP

    I have to re-install Windows to my partition - long story and no need to detail the problem. I deleted the previous partition to start from scratch, re-created the partition with Boot Camp and when it came to installing Windows XP, I didn't get the o

  • DBMS_JOB

    I'm sure you have all had enough questions from me in the past few days! but you all are so helpful i can't stop my self from attempting to get as much help as i can :D its hard to read through documentation 50 pages long when you all usually have a

  • LMS 4.2 Change Audit Report

    Hi, The audit/compliance department at one of costumer wants to see the weekly config change audit report. I have done  many test with this feature and i found two problems: 1. The given report path is empty. Only the directories  was made and there

  • Query execution is not working after transports to Production

    Hello All, I have released a complete data model for SAP HR from BW Dev to BW Prod. But when I generate a query and try to execute it, I am getting the below mentioned error. ANo value could be determined for variable ZEMND001. ESpecify a value for v

  • HTML inside Flash a joke?

    I'm not really sure what's going on here...I've had some bad HTML tranlation on flash's behalf before, but never as bad as this. It seems all my carriage returns are getting displayed and all my <br> tags are being ignored. I'm setting htmlText for s