Multiple buttons in JSP

hi,
I am using a form in a JSP page with a back-end Oracle database. The JSP page displays a row of data from a table in the database, and i have an update button next to each one of them.
The following code is used to create the buttons:
<INPUT type="submit" name="u<%= i %>" value="Update">
where i is the id of the row.
I use the following code on the next page to know which button was pressed
if (request.getParameter("u"+i) != null){
All I want to know if how to replace the buttons on the first page with an image source without loosing the name/value property.
thanks

hi,
i found a soln of the web.
on the form page
<input type="image" name="image" src="image.gif" alt="image" value="image">
on the forwarded page:
if (request.getParameter("image.x")!=null) {
// image button pressed
It works as i want to, but can someone explain why I need this '.x', and why it wont work simply with request.getParameter("image")
thank you

Similar Messages

  • Multiple buttons in jsp page

    Hi to all
    afteradminlogin.jsp:--
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
          <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <h4>Select your Department</h4>
    <br>
    <html:link forward="adminbooks">Java</html:link>
    <br>
    <br>
    <html:link forward="adminbooks">.Net</html:link>
    </body>
    </html>in this page when we click on java link it has to move to the adminbooks .but it is not moving it is showing empty page in that place
    adminbooks.jsp:--
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
          <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <input type="hidden" name="method">
    <h4>Welcome To Selection</h4>
    <table border="1">
    <tr>
    <th>
    sno
    </th>
    <th>
    Book Name
    </th>
    <th>
    Author
    </th>
    <th>
    Available No.of Books
    </th>
    <th>
    Select
    </th>
    </tr>
    </table>
    <html:submit name="add" value="add" >Add</html:submit>
    <html:submit name="edit" value="edit">Edit</html:submit>
    </body>
    </html>in this above jsp page i am using two buttons .in this page when we click on add button it has to go to another page and after submit that page that data has to add the the above table how can done that one
    where add button jsp page
    adminaddbooks.jsp:--
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
        %@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <br>
    Book Name <input type="text" name="bookname">
    <br>
    <br>
    Author <input type="text"  name="author">
    <br>
    <br>
    Available No.of Books <input type="text" name="availablebooks">
    <br>
    <br>
    <input type="submit"  value="submit" name="submit">
    </body>
    </html>strutsconfig.xml:--
    <struts-config>
        <form-beans>
        <form-bean
               name="AdminForm"
               type="org.struts.library.admin.AdminForm">
    </form-beans>
    <global-forwards>
    <forward   
                     name="userlogin"
                     path="/Logon.do"/>
            <forward
                     name="adminlogin"
                     path="/adminlogin.do"/>   
           <forward name="adminbooks"
                    path="/adminbooks.do"/>         
            <forward
                name="home"
                path="/home.do"/>
        </global-forwards>
    <action-mappings>
    <action
             path="/adminlogin"
             forward="/pages/adminlogin.jsp"/>
             <action
                  path="/adminaction"
                  type="org.struts.library.admin.AdminAction"
                  name="AdminForm"
                  scope="request"
                  validate="true"
                  input="/pages/adminlogin.jsp">
             <forward   name="success"
                        path="/pages/afteradminlogin.jsp"/>
             <forward    name="failure"
                         path="/pages/adminlogin.jsp"/>
                         </action>        
                  <action path="/adminbooks"
                         type="org.struts.library.admin.AdminBooksAction"
                        forward="/pages/adminbooks.jsp">
                  <forward name="add"
                          path="/pages/adminaddbooks.jsp"/>
                  <forward name="edit"
                           path="/pages/admineditbooks"/>
                         </action>                           
                  </struts-config>

    if you link to an action doesnt work then maybe your action is wrong but you didnt post it.
    You cannot submit a form if you dont use a form in your code
    Other general advice:
    Study Struts better and make sure you know HTML/JSP
    Get an example running and then start with a simple "Hello Struts" test with an Action that doesnt do much

  • Handling multiple buttons in jsp

    hi guyz,
    I have a requirment where i need to handle different buttons in a single jsp form, where each button has different actions. For example, submit button , cancel button, reset button. It would b really helpful for me if any of u guyz can poste me the code . I know java script method but it wont meet my requirement.
    I appreciate any suggestions or help from ur side. Thanks in advance,
    B.S

    by the word 'different actions' u meaned the value of action attibute in ur form tag, then i guess u will hv to use java scripts..
    but if u want those buttons to perform diff actions
    then for submit button u cd say < type="submit" value="submit" name="btn"submit" > it will submit the current pg to the one specified in the action attribue. similarly for reset u cd say type="reset"...
    and for cancel button, if u wish to go back, then < type=button value=cancel onclick="history.back();" >

  • How to create multiple toolbar buttons in jsp ?

    hi all,
    how to create multiple toolbar buttons in jsp ?
    plz help me

    mgmt
    plzhttp://www.catb.org/~esr/faqs/smart-questions.html#writewell
    How To Ask Questions The Smart Way
    Eric Steven Raymond
    Rick Moen
    Write in clear, grammatical, correctly-spelled language
    We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding (often enough to bet on, anyway). Answering questions for careless and sloppy thinkers is not rewarding; we'd rather spend our time elsewhere.
    So expressing your question clearly and well is important. If you can't be bothered to do that, we can't be bothered to pay attention. Spend the extra effort to polish your language. It doesn't have to be stiff or formal ? in fact, hacker culture values informal, slangy and humorous language used with precision. But it has to be precise; there has to be some indication that you're thinking and paying attention.
    Spell, punctuate, and capitalize correctly. Don't confuse "its" with "it's", "loose" with "lose", or "discrete" with "discreet". Don't TYPE IN ALL CAPS; this is read as shouting and considered rude. (All-smalls is only slightly less annoying, as it's difficult to read. Alan Cox can get away with it, but you can't.)
    More generally, if you write like a semi-literate b o o b you will very likely be ignored. So don't use instant-messaging shortcuts. Spelling "you" as "u" makes you look like a semi-literate b o o b to save two entire keystrokes.

  • Multiple submit button on jsp

    Hello,
    Can I have multiple submit button on single JSP page?
    if its possible then tell me how?
    And how to call multiple functions in JSP?
    reply me urgent

    I think this code will help you
    <html>
         <head></head>
         <script>
              function submitForm(clickedButton){
                   if(clickedButton.name =="button1"){
                        alert("button1");
                        document.multipleSubmitDemoForm.action="linkToJSPWhenFirstButtonClicked.jsp";
                   }else if(clickedButton.name =="button2"){
                        alert("button2");
                        document.multipleSubmitDemoForm.action="linkToJSPWhenSecondButtonClicked.jsp";
                   }else if(clickedButton.name =="button3"){
                        alert("button3");
                        document.multipleSubmitDemoForm.action="linkToJSPWhenThirdButtonClicked.jsp";
                   document.multipleSubmitDemoForm.submit();
         </script>
         <body>
              <form name="multipleSubmitDemoForm" method="POST" action="" >
                   <input type="button" name="button1" onClick=submitForm(this) />
                   <input type="button" name="button2" onClick=submitForm(this) />
                   <input type="button" name="button3" onClick=submitForm(this) />
              </form>
         </body>
    </html>

  • How to use one pop up window for multiple buttons and input fields?

    Hi Experts,
    I have created a pop up window that will be opened from multiple buttons in the same view. There are input fields that the data will be populated from a pop up window.  How can I set up which button that a pop up window is opened from? I also would like to populate the data from a pop up window to the input field next to a clicked button. There are 6 buttons and 6 input fields that share the same pop up window. I would very appreciate your responses.
    Thank you,
    Don

    Hi,
    Try creating 2 context attributes, one in your component controller and the other in the pop-up view. Bind the attribute of pop-up view to the component controller attribute.
    In the main view, on click of every button set a unique code in the controller's context which helps you in identifying the button clicked. Since u have created a binding to the pop-up view attribute the value flows from the controller.
    In the init method of your pop-up view, check the value of the attribute and based on that display which ever UI elements are required.
    Eg:
    On Button 1 click set value "B1", Button 2  value "B2" etc. In the init() of pop-up view u can check the values and perform the required operation:
    if(("B1").wdContext().currentContextElement().getButtonIdentifier()){
    else...{
    Hope this helps you.
    Regards,
    Poojith MV

  • Multiple buttons on a single slide each connecting to a different url

    Using a trial version of Captivate 7.  I have a handful of slides where the customer wants to open different forms via url.  I tried using a button for each link, inserting the url and using the "enter" key for each of the multiple buttons.  Works fine with the mouse but for 508 folks who tab to the URL and hit the enter key ......... I get many instances where the incorrect url is activated.  Is there a way around this without assicning a different shortcut key for buttons where thare are more than one on a single slide?     Thanks

    Welcome to AD!
    Here is an article on using multiple ipods. I suggest method 1 and steer clear of method 3.
    http://support.apple.com/kb/HT1495
    For your point #1, sharing music on same PC between users, put it in a shared library & set permissions as directed here
    http://support.apple.com/kb/HT1203
    For #2, itunes doesn't have the capability to monitor folders for new content. You'll need to get something like the free program 'itunes folder watch'.

  • To open a window & html page at a time on a single button, in JSP.

    Hello!
    I want to open 1 window as well as i want to open 1 html page on a single button click at a same time, in JSP.
    on button's "action" event i am opening the html page and button's "onclick" event i am opening the window, but it is not showing these 2 actions at a time. only window gets open when i click the button.
    [Also on form's "action" event i am having validate() function.]
    how do i open a window & html page at a time on a single button, in JSP?
    I don't know how to do this. I have stuck over here, if anyone is having any solution, please let me know.
    I need your help.
    Thank You.

    write js as
    window.open(page, "Popup", windowprops);
    windowprops = "height="+hi+",width="+wd+",top="+ wint +",left="+ winl +",location=no,"
              + "scrollbars=yes,menubars=no,toolbars=no,resizable=no,status=yes";
              encapsulate this in one function and call that function on button click event !!

  • I have a button in JSP page inside an UIWebView by pressing the button i want to run another existing iPhone native application in background only.Do anyone have a solution for this.

    I have a button in JSP page inside an UIWebView by pressing the button i want to run another
    existing iPhone native application in background only.Do anyone have a solution for this.

    Sounds like a virus.... I hope it's not...
    Launching Other Apps within an iPhone

  • How to add multiple button/choices in  button choice

    HI all ,
            How to add multiple button/choices in  button choice ?

    Initialize a cluster array (CrsrList type) with as many cursors as you think you would ever need.   Setup your cursors dynamically, then delete the unused cursors (array elements) and then update your CursorList property.
    Message Edited by vt92 on 03-20-2009 04:04 PM
    "There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
    Attachments:
    cursors.PNG ‏5 KB

  • How to create multiple buttons in ALV Toolbar in Webdynpro ABAP

    Hi all,
    I am trying to create multiple buttons in Webdynpro  ALV toolbar, please go through the code.
    What happening is, second button is replacing the first one.
    DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
       lo_cmp_usage =   wd_this->wd_cpuse_alv_table( ).
       IF lo_cmp_usage->has_active_component( ) IS INITIAL.
         lo_cmp_usage->create_component( ).
       ENDIF.
       DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
       lo_interfacecontroller =   wd_this->wd_cpifc_alv_table( ).
        DATA lv_value TYPE REF TO cl_salv_wd_config_table.
       lv_value = lo_interfacecontroller->get_model(
       DATA lr_buttonui1 TYPE REF TO cl_salv_wd_fe_button.
       DATA lr_buttonui2 TYPE REF TO cl_salv_wd_fe_button.
       DATA button1 TYPE REF TO cl_salv_wd_function.
       DATA button2 TYPE REF TO cl_salv_wd_function.
    **First button
       CREATE OBJECT lr_buttonui1.
       lr_buttonui1->set_text('Button')."setting the text of the button on alv toolbar
       button1 = lv_value->if_salv_wd_function_settings~create_function( id = 'BUTTON')."creating the function for alv button
       button1->set_editor( lr_buttonui1 ).
    **Second button
       CREATE OBJECT lr_buttonui2.
         lr_buttonui2->set_text('Button1')."setting the text of the button on alv toolbar
       button2 = lv_value->if_salv_wd_function_settings~create_function( id = 'BUTTON' )."creating the function for alv button
       button2->set_editor( lr_buttonui2 ).
    How can I overcome this??
    Thanks
    Eshwar

    Hi Eshwar,
    The button Ids are same for both the buttons in your code. You need to change it as BUTTON1, BUTTON2.
    **First button
       CREATE OBJECT lr_buttonui1.
       lr_buttonui1->set_text('Button')."setting the text of the button on alv toolbar
       button1 = lv_value->if_salv_wd_function_settings~create_function( id = 'BUTTON1')."creating the function for alv button
       button1->set_editor( lr_buttonui1 ).
    **Second button
       CREATE OBJECT lr_buttonui2.
         lr_buttonui2->set_text('Button1')."setting the text of the button on alv toolbar
       button2 = lv_value->if_salv_wd_function_settings~create_function( id = 'BUTTON2' )."creating the function for alv button
       button2->set_editor( lr_buttonui2 ).

  • Print button in JSP

    Is it possible to create a PRINT button in JSP which will also "shrink-to-fit" the page too when printing?
    i'm new to JSP as some people know... thank you

    the system im making is for people with very small knowledge of computers and wouldnt know how to shrink to fit a page in print preview... so i want to create a button on the website which will do this for them

  • How prevent simultaneous execution of multiple button threads?

    My AS 3 program has multiple buttons. Users can select one and then immediately select another and this causes 2 threads that collide.  Once one button is executing, I want the other buttons to ignore clicks.
    I've tried using a lock:Boolean to indicate a button is being processed.  Each button checks lock.  My logic is such that when the AS 3 processor detects a locked condition, it abandons execution of that button.  However, surprisingly, it abandons execution only termporarily ... once the the boolean is unlocked, AS 3 comes back and executes the button.
    The problems are twofold:  1)  the first time the 2nd button attempts to execute (by checking lock), when it returns (from checking lock) and attempts to pick up processing where it left off, it seems to forget where it was and does not utlimately complete its task(s); possibly variables have been altered, it is difficult to say.  That is, AS 3 is unable to successfully pickup where it left off on the first button.
    2) the second problem is that AS 3 incorrectly returns to button 2 after the lock condition is cleared.  It persists and will execute that button.
    Can anyone tell me how once one button is selected, the others can be locked out and won't execute??  Multiple threads from these buttons is a problem.
    Thanks in advance.
    Steve @ U Iowa

    dmennenoh - OK.  The downside to that type of solution is that each button has to "know" which other buttons are on the stage at that time, but, yes, that should work.  Do you think turning their visibility off would or would not be as effective as removing the event listeners?  I'm thinking turning visiblity on or off is simpler and simpler to manage.  Thanks for your help.

  • Multiple Buttons in JTable Headers:  Listening for Mouse Clicks

    I am writing a table which has table headers that contain multiple buttons. For the header cells, I am using a custom cell renderer which extends JPanel. A JLabel and JButtons are added to the JPanel.
    Unfortunately, the buttons do not do anything. (Clicking in the area of a button doesn't appear to have any effect; the button doesn't appear to be pressed.)
    Looking through the archives, I read a suggestion that the way to solve this problem is to listen for mouse clicks on the table header and then determine whether the mouse clicks fall in the area of the button. However, I cannot seem to get coordinates for the button that match the coordinates I see for mouse clicks.
    The coordinates for mouse clicks seem to be relative to the top left corner of the table header (which would match the specification for mouse listeners). I haven't figured out how to get corresponding coordinates for the button. The coordinates returned by JButton.getBounds() seem to be relative to the top left corner of the panel. I hoped I could just add those to the coordinates for the panel to get coordinates relative to the table header, but JPanel.getBounds() gives me negative numbers for x and y (?!?). JPanel.getLocation() gives me the same negative numbers. When I tried JPanel.getLocationOnScreen(), I get an IllegalComponentStateException:
    Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
    Can someone tell me how to get coordinates for the button on the JTableHeader? Or is there an easier way to do this (some way to make the buttons actually work so I can just use an ActionListener like I normally would)?
    Here is relevant code:
    public class MyTableHeaderRenderer extends JPanel implements TableCellRenderer {
    public MyTableHeaderRenderer() {
      setOpaque(true);
      // ... set colors...
      setBorder(UIManager.getBorder("TableHeader.cellBorder"));
      setLayout(new FlowLayout(FlowLayout.LEADING));
      setAlignmentY(Component.CENTER_ALIGNMENT);
    public Component getTableCellRendererComponent(JTable table,
                                                     Object value,
                                                     boolean isSelected,
                                                     boolean hasFocus,
                                                     int row,
                                                     int column){
      if (table != null){
        removeAll();
        String valueString = (value == null) ? "" : value.toString();
        add(new JLabel(valueString));
        Insets zeroInsets = new Insets(0, 0, 0, 0);
        final JButton sortAscendingButton = new JButton("1");
        sortAscendingButton.setMargin(zeroInsets);
        table.getTableHeader().addMouseListener(new MouseAdapter(){
          public void mouseClicked(MouseEvent e) {
            Rectangle buttonBounds = sortAscendingButton.getBounds();
            Rectangle panelBounds = MyTableHeaderRenderer.this.getBounds();
            System.out.println(Revising based on (" + panelBounds.x + ", "
                               + panelBounds.y + ")...");
            buttonBounds.translate(panelBounds.x, panelBounds.y);
            if (buttonBounds.contains(e.getX(), e.getY())){  // The click was on this button.
              System.out.println("Calling sortAscending...");
              ((MyTableModel) table.getModel()).sortAscending(column);
            else{
              System.out.println("(" + e.getX() + ", " + e.getY() + ") is not within "
                                 + sortAscendingButton.getBounds() + " [ revised to " + buttonBounds + "].");
        sortAscendingButton.setEnabled(true);
        add(sortAscendingButton);
        JButton button2 = new JButton("2");
        button2.setMargin(zeroInsets);
        add(button2);
        //etc
      return this;
    }

    I found a solution to this: It's the getHeaderRect method in class JTableHeader.
    table.getTableHeader().addMouseListener(new MouseAdapter(){
      public void mouseClicked(MouseEvent e) {
        Rectangle panelBounds = table.getTableHeader().getHeaderRect(column);
        Rectangle buttonBounds = sortAscendingButton.getBounds();
        buttonBounds.translate(panelBounds.x, panelBounds.y);
        if (buttonBounds.contains(e.getX(), e.getY()) && processedEvents.add(e)){  // The click was on this button.
          ((MyTableModel) table.getModel()).sortAscending(column);
    });

  • Multiple buttons for a given validation

    I want the same validation to be done on the click of two buttons. In the "Conditional Validation Processing", I see we can
    "select a button" which allows us to select only one button.
    How can I select multiple buttons for a given validation?
    Is there a way or do I need to create another validation for the second button.
    Please advice.

    When you submit a page with a button the "request" value is set to the button name (not the displayed button label). After-submit events can check the request using :REQUEST or v('REQUEST') so you can build a condition like:   :REQUEST in ('APPLY','CREATE')..or you can use a built-in condition type that checks the request value like 'Request is Contained within Expression 1'.
    Scott

Maybe you are looking for

  • I would like to see a built-in way of adding audio and video files.

    As it is, you have to rely on third-party solutions for adding mp3 audio files and video to Muse sites. Thanks

  • Reading Lots of Objects into Memory

    I need to read thousands of fairly large objects from an object database to the point that the JMV memory runs out. A solution is to: read, use and discard as opposed to loading all the objects into memory at once -pretty simple but I want to do it r

  • Local Host Problem

    Hi, I'm new to both macs and apache, and I have run into a problem while installing mysql and php. I have been using a online video tutorial from lynda.com but I can't seem to access the localhost. I tried the http://localhost/~(username)/ but all it

  • Migrated CS6 from my desktop to laptop since old one's motherboard died and AE can't find Bridge

    Do I really need to reinstall everything or just Bridge?  And when I open Bridge separately, it crashes trying to open application folder.

  • JavaFx and fxml in a OSGI runtime

    hello, I'm working to run javafx in the Apache felix osgi runtime, using Bundle-NativeCode and lots of Import/Export-Package I make an javafx bundle, that work properly to run javaFx interfaces write in plain java... but, when I try to load an fxml f