Simple Doubt in JSP

I have a set of check boxes and corresponding text boxes in a HTML form. I want to display the text box value if the corresponding check box is checked.
Can anybody tell me how to accomplish this?

I have a set of check boxes and corresponding text
boxes in a HTML form. I want to display the text box
value if the corresponding check box is checked.
Can anybody tell me how to accomplish this?when are you trying to display the text box value? After they hit a submit button or something? If thats true then you can if you want write a servlet or jsp which will handle the POST action. Then you can get the value depending on what you named it in them in the JSP.
So if you named your field something like:
<input type="text" name="text_one"/><input type="checkbox" name="mycheckbox" value="one"><br>
<input type="text" name="text_two"/><input type="checkbox" name="mycheckbox" value="two"><br>
<input type="text" name="text_three"/><input type="checkbox" name="mycheckbox" value="three"><br>
Now you can do:
String[] checkBoxValues = request.getParameterValues("mycheckbox");
for(int i = 0; i < checkBoxValues.length; i++) {
if(checkBoxValues.equals("one"))
System.out.println(request.getParameter("text_one");
else if(checkBoxValues[i].equals("two"))
System.out.println(request.getParameter("text_two");
else if(checkBoxValues[i].equals("three"))
System.out.println(request.getParameter("text_three");
Obviously there probably way better ways to do this but this should at least lead you in the right direction.
-Chuy

Similar Messages

  • Doubt in JSP recordset

    Hi i have a doubt in jsp...first i don know much abt jsp so iam gonna trying out a project on supermarket system.Here i have three tables Items,Bill and Report.Iam using three resultset continuously and i have error saying no resultset found.I have sent the code can anyone plz help me correcting it.
    <%
    String item= request.getParameter("itemadd");
    String qr=request.getParameter("quanreq");
    HttpSession Dsess=request.getSession();
    String refer = (String)Dsess.getAttribute("user");
    Date dd = new Date();
    SimpleDateFormat sdf1 = new SimpleDateFormat("dd");
    String date = sdf1.format(dd);
    Date mm = new Date();
    out.println(date);
    SimpleDateFormat sdf2 = new SimpleDateFormat("MMM");
    String mon = sdf2.format(mm);
    Date yy = new Date();
    SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy");
    String year = sdf3.format(yy);
    try
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         Connection con=DriverManager.getConnection("jdbc:odbc:honeydew"," "," ");
         Statement st= con.createStatement();
         ResultSet rs = st.executeQuery("Select * from Items where Iname = '"+item+"' ");
         String uni = new String();
         String pri = new String();
         while(rs.next())
              uni = rs.getString(4);
              pri = rs.getString(5);
         ResultSet rs4 = st.executeQuery("update Items set Quantity = Quantity - '"+qr+"' where Iname ='"+item+"' ");
         ResultSet rs2 = st.executeQuery("insert into Bill values('"+item+"','"+qr+"','"+uni+"','"+pri+"','"+refer+"')");
         ResultSet rs2 = st.executeQuery("insert into Report values('"+item+"','"+qr+"','"+uni+"','"+pri+"','"+date+"','"+mon+"','"+year+"')");
    catch(Exception e)
    %>
    <html>
    <body bgcolor="#CCDDEF">
    <%@ page import = "java.sql.*" %>
    <%@ page import = "java.lang.*" %>
    <%@ page import = "java.util.Date" %>
    <%@ page import = "java.text.*" %>

    Hi
    When you are doing either update or insert database operations, use Statement.executeUpdate("insert . . . . "), which will return how many rows are effected. So instead of
    ResultSet rs1 = stmt.executeQuery("update ......"); use the following
    stmt.excuteUpdate("update ...... ");

  • EXTRACTing to TEXT file in Data Warehouse - Simple doubts!

    Hi Experts,
    Pls. clarify my simple doubts, in data EXTRACTing prog.,(data extract from SAP to text file in Application server, prog. runs in back ground)
    For the Dataware house mapping, I hv been asked to make the following changes,
    1) Presently, there is NO column headings in Text file, so I need to add the column Headings - How to get it done?
    2) presently, its NOT tab deliminated, so, I need to make it to TAB deliminated- How to achieve it?
    I am here paste some piece of code, so that U will get understand well.
    PERFORM open_dataset_zdata_whouse_04.
        DESCRIBE FIELD i_tab LENGTH tfr_length IN BYTE MODE.
        LOOP AT i_itab.
          TRANSFER i_itab TO transfer_file1 LENGTH tfr_length.
        ENDLOOP.
        CLOSE DATASET transfer_file1.
    ThaNQ.

    See the below code :
    parameters: d1 type localfile default
    '/usr/sap/TST/SYS/Test.txt'.
    data: begin of itab occurs 0,
          field1(20) type c,
          field2(20) type c,
          field3(20) type c,
          end of itab.
    data: str type string.
    constants: con_tab type x value '09'.
    if you have a newer version, then you can use this
    instead.
    *constants:
       con_tab  type c value
    cl_abap_char_utilities=>HORIZONTAL_TAB.
    start-of-selection.
    itab-field1 = 'ABC'.
    itab-field2 = 'DEF'.
    itab-field3 = 'GHI'.
    append itab.
    itab-field1 = '123'.
    itab-field2 = '456'.
    itab-field3 = '789'.
    append itab.
      open dataset d1 for output in text mode.
      loop at itab.
        translate itab using ' # '.
        concatenate itab-field1 itab-field2 itab-field2
    into str
                      separated by con_tab.
        translate str using ' # '.
        transfer str to d1.
      endloop.
      close dataset d1.
    above code for tab delimited.
    for heading then you can write simple logic in the loop of internal table
    loop at itab.
    if sy-tabix = 1'
    move heading data to file.
    endif.
    endloop.
    Thanks
    Seshu

  • Simple and Free JSP Editor Plugin for Eclipse

    Can anyone direct me a Simple and Free JSP Editor Plugin for Eclipse ? Thanks

    You can just create JSP files with "Eclipse for Java EE".
    What do you expect of the plugin then?

  • How to show simple chinese in jsp

    when I use simple chinese in jsp,in the portlet all the char convert into B>B-C&#147;B*B;C.B6B/,but in the servlet,all the simple chinese char it right,I have set the conentType = "text/html;gb2312",but the problem is still.
    somebody can help me!
    thanks!

    You have to set the content type on your response firts.
    eg; response.setContentType("image/gif");

  • A very simple doubt w.r.t ESB

    Hi All
    I have a very simple doubt yet very important for all the new BPEL guys (I feel so )
    I am doing order booking example as part of my BPEL learning!!
    My doubt is:
    When Client application calls OrderBookingESB , a message is being sent on the ESB.my Q is if the user places two different orders in a same session ,then will there be two messages on the same instance of ESB (assuming first message is not consumed b4 placing the second order) or two instances of ESB will get created each having one Message.
    And is it anytime possible that an ESB instance can have more than one message.??
    pls clarify once.
    thanks
    naveen

    Every time you send a message to the bus..it will create an instance for.
    There is no such thing as 'same' session on the bus..it just receives the messages and does his thing with it.
    So when you send both messages to the bus (wheter or not it maybe be in the same session) you will still get 2 new instances..and both instances will start his own processes for lets say the bpel...so you will also have 2 instances of the bpel process.
    "ESB instance can have more than one message"
    if i've understand you correctly i would say no.....1 message on the bus is 1 instance of your esb project. Between the different components in your esb project there will be new messages constructed...but to start with..it just needs 1 message

  • Using simple functions in JSP

    Hi to all,
    I would to use simple functions in my jsp page.
    I 've created the function with the tags <%! ... %>
    My problem is that i don't succed to call there from the page.
    How i can to do ?
    I've tried also with java beans but i'm not very clever with there also so i don't can to go forward !!!
    Please help me. thanks

    Hi, a new problem rises now.
    the problem is into the method ctr_data().
    Under i put the jsp code and the error:
    Anyone can see where is the error please?
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@page import= "java.sql.*,  java.lang.*" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <title>Progetto Sofia - Registrazione utente</title>
    </head>
    <%!
    public boolean ctr_lunghezza(String s1){
        if (s1.length() == 0) return false;
        return true;
    %>
    <%!
    public boolean isLeapYear(int year) {
           if (year%400 == 0)  return true;
           if ((year%4 == 0) && (year%100 != 0))return true;
           return false;
    %>
    <%!
    public boolean ctr_data (String gg, String mm, String aa){
        int anno = Integer.valueOf(aa).intValue();
        int mese = Integer.valueOf(mm).intValue();
        int giorno = Integer.valueOf(gg).intValue();
        if ((gg.length() == 0) || (mm.length() == 0) || (aa.length() == 0))
            return false;
        if ((anno < 1905) || (anno > 2005))
            return false;
        if (mese == 2){
            if (isLeapYear(anno)){
                if (giorno > 29) return false;
            }else{
                if (giorno > 28) return false;
        if ((mese == 11) || (mese == 4) || (mese == 6) || (mese == 9)){
            if (giorno == 31) return false;
        return true;
    %>
    <%
    int flag = 0;
    String risposta = "";
    String temp ="";
    temp = (request.getParameter("nome_utente")!=null)?request.getParameter("nome_utente") :"";
    if (ctr_lunghezza (temp) == false){
       risposta = risposta.concat("Attenzione --- Riempire il campo: Nome\n");
       flag++;
    temp = (request.getParameter("cognome_utente")!=null)?request.getParameter("cognome_utente"):"";
    if (!ctr_lunghezza (temp)){
        risposta = risposta.concat("Attenzione --- Riempire il campo: Cognome\n");
        flag++;
    String gg1 = (request.getParameter("giorno_n_utente")!=null)?request.getParameter("giorno_n_utente"):"0";
    String mm1 = (request.getParameter("mese_n_utente")!=null)?request.getParameter("mese_n_utente"):"0";
    String aa1 = (request.getParameter("anno_n_utente")!=null)?request.getParameter("anno_n_utente"):"0";
    if (!ctr_data(gg1, mm1, aa1)){
        risposta = risposta.concat("Attenzione --- Data di nascita non corretta\n");
        flag++;
    temp = (request.getParameter("luogo_n_utente")!=null)?request.getParameter("luogo_n_utente"):"";
    if (!ctr_lunghezza (temp)){
        risposta = risposta.concat("Attenzione --- Riempire il campo: Luogo di nascita\n");
        flag++;
    temp = (request.getParameter("res_utente")!=null)?request.getParameter("res_utente"):" ";
    if (temp == "Seleziona"){
        risposta = risposta.concat("Attenzione --- Selezionare il Comune di Residenza\n");
        flag++;
    temp = (request.getParameter("ind_utente")!=null)?request.getParameter("ind_utente"):" ";
    if (!ctr_lunghezza(temp)){ 
        risposta = risposta.concat("Attenzione --- Riempire il campo Indirizzo\n");
        flag++;
    %>and this is the error msg:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: For input string: ""
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    java.lang.NumberFormatException: For input string: ""
         java.lang.NumberFormatException.forInputString(Unknown Source)
         java.lang.Integer.parseInt(Unknown Source)
         java.lang.Integer.valueOf(Unknown Source)
         org.apache.jsp.progetto.w2.web.Reg_005futente_jsp.ctr_data(org.apache.jsp.progetto.w2.web.Reg_005futente_jsp:27)
         org.apache.jsp.progetto.w2.web.Reg_005futente_jsp._jspService(org.apache.jsp.progetto.w2.web.Reg_005futente_jsp:122)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

  • Simple Doubt in BDC

    Hi friends,
       I am new to BDC .I am just trying a simple code which is written already.
       This is the simple code to fill the transaction VK13 first screen.
      PERFORM bdc_dynpro      USING 'SAPMV13A' '0100'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                          'RV13A-KSCHL'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                            '/00'.
      PERFORM bdc_field       USING 'RV13A-KSCHL'
                                           wa_report-kschl.
      PERFORM bdc_dynpro      USING 'SAPLV14A' '0100'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                          'RV130-SELKZ(01)'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                           '=WEIT'.
      PERFORM bdc_field       USING 'RV130-SELKZ(01)'
                                            'X'.
      CALL TRANSACTION 'VK13' USING i_bdc_tbl
                              MODE  'A'.
    FORM bdc_dynpro USING program dynpro.
      CLEAR i_bdc_tbl.
      wa_bdc_tbl-program  = program.
      wa_bdc_tbl-dynpro   = dynpro.
      wa_bdc_tbl-dynbegin = 'X'.
      APPEND wa_bdc_tbl TO i_bdc_tbl.
    ENDFORM.                    "BDC_DYNPRO
    FORM bdc_field USING fnam fval.
      CLEAR i_bdc_tbl.
      MOVE fnam TO wa_bdc_tbl-fnam.
      MOVE fval TO wa_bdc_tbl-fval.
      APPEND wa_bdc_tbl TO i_bdc_tbl.
    ENDFORM.                    "BDC_FIELD
    When execute this code it is just showing the empty screen of transaction vk13. It is not filling the condition type field with whatever value i am passing. When go in debugg mode i am not getting the logic again and again it is going to the first screen of vk13 and asking to enter the value whwn the statement CALL TRANSACTION is getting executed. It is clear to me.
    My main doubt is we are clearing the internal table i_bdc_tbl before calling the transaction once we move the value to the specific field.I am not getting what they tried to do there.Simply moving one record to internal table and again clearing it then moving a next record and clearing it again before calling the transaction.
    What we are trying to do by this?Can any one explain me.
    Please help me out in understanding this.
    Thanks in Advance.

    Hi Shri,
    You can go thru these links for more info on BDC:
    http://help.sap.com/saphelp_erp2005/helpdata/en/fa/097119543b11d1898e0000e8322d00/frameset.htm
    http://www.sapbrain.com/TUTORIALS/TECHNICAL/BDC_tutorial.html
    http://www.sap-img.com/abap/learning-bdc-programming.htm
    http://www.sap-img.com/bdc.htm
    www.sappoint.com/abap/bdcconcept.pdf
    http://www.sap-img.com/abap/learning-bdc-programming.htm
    http://www.sapdevelopment.co.uk/bdc/bdchome.htm
    http://www.planetsap.com/bdc_main_page.htm
    Reward points if this helps.
    Manish

  • How deploying a simple report as .jsp

    Hi,
    i have read the last days many document, and messages on this board.
    But I could not find answers.
    My problem is:
    I create a simple report with reportbuilder and save this to mysample.jsp.
    I copy this file to Oracle Application Server j2ee\OC4J_BI_Forms\applications\reports\web\.
    When i call the report from web http://myservername/reports/mysample.jsp?userid=.
    The server return follow error:
    Anforderungs-URI:/reports/JSP_Demo.jsp
    Exception:
    java.io.FileNotFoundException
    Oracle Application Server Forms and Reports Services 10g (9.0.4.0.1) for Microsoft Windows with Patch Set 2 (9.0.4.2.0)

    Are you sure you're copting the Reports to the right place. There's a difference running Developer Suite and Application Server. Check documentation and/or Metalink. Also, I would place this question next time in the Reports forum, not in the Application Server (General) forum:
    Reports
    Martin

  • Simple question from jsp newbie

    Hi friends,
    I am learning jsp now. Reading documents and implementing simple applications. But i want to ask a question that is opposite to my logic.
    Now, i am a textfield control on jsp as textField1. I have created this control from Palette. in java code i am writing "textbox1." but there is no action, no intellisense while pressing ctrl + space.
    How the control is accessing from java code? Maybe my logic with visual studio .net. but i want to learn jsp logic.
    Thanks.

    technologyMan wrote:
    I am learning jsp now. You´re actually at the JSF forum here.
    Now, i am a textfield control on jsp as textField1. You are? Really?
    I have created this control from Palette. in java code i am writing "textbox1." but there is no action, no intellisense while pressing ctrl + space.
    How the control is accessing from java code? Maybe my logic with visual studio .net. but i want to learn jsp logic.Uh, just write code accordingly? You can use h:commandButton/h:commandLink for that.
    Anyway, if you want to start with JSF, I can recommend you the following sources:
    Java EE tutorial part II, JSF starts at chapter 10: [http://java.sun.com/javaee/5/docs/tutorial/doc/]
    Good kickoff tutorial: [http://balusc.blogspot.com/2008/01/jsf-tutorial-with-eclipse-and-tomcat.html]
    The JSF taglib documentation: [http://java.sun.com/javaee/javaserverfaces/1.2/docs/tlddocs/]
    The JSF API documentation: [http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/overview-summary.html]

  • Help me -doubt in jsp

    hai
    In my jsp page one checkbox is there.
    when i check the checkbox then another on textarea will popup
    and vice versa
    plese help me
    it is very urgent
    thank you

    * dont doubt JSP it has proven its worth.
    * checking checkbox and hidding/showing textareas is not in your JSP but in the HTML that is send to your client by making a request to your JSP, its a detail but a very important one
    * This means you need Javascript that will change the style of yor HTML components, have a look at a javascript onclick or onchange events and at the DOM model.
    * example
    yourtextarea.style.visibility = 'hidden'

  • Simple doubts with scenarios and services

    One simple and "basic" doubt
    Imagine I had developed an IDOC-IDOC scenario or File-IDOC, it doesn't matter...
    In my Integration Directory all the services and receivers, senders agreements and determinations remain there...
    First Doubt:
    How can I make them visually disappear without deleting them? Meaning, how can I disable them?
    Second Doubt:
    At the moment I would like to start another scenario, but that scenario will use one of the business systems created. How can I disable the other the interface determination and the receiver agreement from the other service, so that the older service won't get in execution?
    When I activate the new service, he runs the older one instead of the newer...
    Any help

    hello gonacalo...
    u r misunderstanding a few things...
    when u use the term scenario, its meant for a whole development...
    within an scenario u can have different business systems which r assigned to various sender/receiver channels and interfaces...
    u can disable the communication channels and not the interfaces because they r meant specificallly as senders or receivers...
    when a user opens a scenario , he can open his own business system components..and if u want all the determinations, agreements to be not viewed by the user in a single scenario , u may well add them to a different scenario....
    hope this eases u a bit...
    regards..
    vishal

  • Simple linkchecker in jsp

    Thanks in advance,
    Hello,
    in order to build a simple jsp, that enables to check links, i tried to modificate the class "GetURLInfo". The idea is simply reading out the http-header, and print out the Response Message and Code.
    Unfortunately i dont know how to make this class able to take the url as a String-Object? Can anyone help me out, please?
    Greetings from Hamburg,
    Bj�rn
    import java.net.*;
    import java.io.*;
    import java.util.Date;
    public class GetURLInfo {
    public static void printinfo(URL url) throws IOException {
    URLConnection c = url.openConnection(); // Get URLConnection from the URL
    c.connect(); // Open a connection to the URL
    // Display some information about the URL contents
    System.out.println(" Content Type: " + c.getContentType());
    System.out.println(" Content Encoding: " + c.getContentEncoding());
    System.out.println(" Content Length: " + c.getContentLength());
    System.out.println(" Date: " + new Date(c.getDate()));
    System.out.println(" Last Modified: " + new Date(c.getLastModified()));
    System.out.println(" Expiration: " + new Date(c.getExpiration()));
    // If it is an HTTP connection, display some additional information.
    if (c instanceof HttpURLConnection) {
    HttpURLConnection h = (HttpURLConnection) c;
    System.out.println(" Request Method: " + h.getRequestMethod());
    System.out.println(" Response Message: " + h.getResponseMessage());
    System.out.println(" Response Code: " + h.getResponseCode());
    /** Create a URL object, call printinfo() to display information about it. */
    public static void main(String[] args) {
    try { printinfo(new URL(args[0])); }
    catch (Exception e) {
    System.err.println(e);
    System.err.println("Usage: java GetURLInfo <url>");

    I'm not sure if I got you right. Do you want to have another signature for printinfo()?
    The solution then is:
    public static void printinfo(String urlString) throws IOException, MalformedURLException {
      URL url = new URL(urlString);
    }

  • How to call a simple bean from jsp in weblgic 6.1

    Hi All,
    Can any one help me , my problem is i have a jsp that is calling a simple bean method for displaying a message .
    When im trying to call the beans methods it conntinusly giving me error unable to resolve the Beans' name
    my jsp content is:
    <%@ page language="java" import="com.Arvind*"%>
    <jsp:useBean id="mybean" scope="session" class="com.Arvind" />
    <%
         out.println("Hello"+mybean.callMe());
    %>
    beans is :-
    package com;
    public class Arvind
         private String st ="This Is Me??";
         public String callMe(){
              System.out.println("Hello World!");
              return st;
         public static void main(String[] args)
              System.out.println("Hello World!");
    i have tried it a lot but all time it fails resolve the class name itself ??
    can anyone please help me urgently
    thanks in advance
    rgds
    Birendar

    It might compile perfectly well, but the message suggests that you didn't deploy it properly. The class loader can't find it.
    That .class file should appear with its package directory structure under the WEB-INF/classes directory or in a JAR in your WEB-INF/lib directory in some WAR file. Does it?

  • Doubt in JSP

    hi ,
    i was new to JSP, when iam learning jsp, i worte a jsp file for performing session tracking using jsp:usebean tag , for that i create a bean and i generate a class and i put that class in classes folder.
    here i got a problem, when i call this in browser i got an error...... class not found. after trying 3 to 4 times i got the same error. i dont know why the error. i wrote all the code correctly and i deploy my application perfectly.
    after that i got an idea to put that class in a package now i got the result without any error.
    Why did we create a new package to perform beans????????

    There's no doubt in my mind you are correct. :)
    Or did I just prove you wrong beyond a doubt? ;)
    Neither. He used the construct "to have a doubt" as a verb, which is incorrect as the word can't be used like that.
    Of course even if it could the very meaning of the word is quite different from the intended "question" as "doubt" doesn't mean question at all but rather "reservation" (and no, that's not a reservation to a theater seat or restaurant table).

Maybe you are looking for

  • Getting error while writing JUnit test case for RestFul Services

    Hi All, I have written Restful services in Netbean 6.8. It's running well...no issues. {color:#0000ff}While writing JUnit test cases for them, I am getting following error: {color}{color:#993300}Testcase: testGetAuthenticated(com.ct.services.LoginSer

  • Import Function Problem.

    I made a new ICT with a name of "DrawSquare" and imported the code my teacher gave me. * DrawSquare This class will create a piece of paper and a pencil, * place the pencil on the paper and then draw a square 100 units on * each side. * @author G. Pe

  • Definitons of scema,direcotry,dictionary,control file,library..please help

    hi , Can you please tell me the defintions of scema,direcotry,dictionary,control file amd library in oracle Please help me by giving the definitions.....

  • Forms 10g  tool_env.getvar

    I work on UNIX and run my form 10g on web. If I execute, e.g. tool_env.getvar('HOME') , I get $ORACLE_HOME instead of current user $HOME. By the way, I use different environments to create log files by text_io.fopen etc. I need all users client envir

  • How to enable Edit in UI Element Table

    Halo Gurus, I am trying a application where user gives the BP number and press Display, it displays the details. Another Button 'Edit' which goes to another view and here I am displaying the details of the given BP number. But n here I need the field