Drop Down list issues in jsp

Hi,
I am facing an issue with drop down list in jsp pages on page postback. Let me explain in detail. I have a client.jsp page which has a drop down list and a text box. The drop down list is populated from an Action class (lets say testAction.java). In the client action form class there is a validation which requires the user to enter some value in the text box.
So here is the problem, when the client.jsp page loads, the drop down list is populated perfectly, but then the user clicks submit button without entering anything in the textbox, the page loads again with an error message ("Please enter some value in the textbox"). At this point the drop down list does not contain any value. Any ideas what could I do?
I am posting the code here for individual pieces,
Struts-config.xml_
<action path="/client" type="com.myapp.struts.testAction" scope="session">
<forward name="success" path="/createClient.jsp"/>
</action>
<action input="/createClient.jsp" name="ClientActionForm" path="/createClient" scope="session" type="com.myapp.struts.ClientAction">
<set-property property="cancellable" value="true" />
<forward name="success" path="/loginSuccessful.jsp"/>
<forward name="cancel" path="/Welcome.do"/>
</action>
index.jsp_
<h5><html:link action="/client" styleClass="purplelink">Create a new client</html:link></h5>
testAction.java_
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ArrayList<String> arrList = new ArrayList<String>();
arrList.add("sports");
arrList.add("music");
arrList.add("test 1");
arrList.add("test2");
request.setAttribute("mylist", arrList);
return mapping.findForward(SUCCESS);
createClient.jsp_
<select name="droplist">
<c:forEach var="itemName" items="${mylist}">
<option><c:out value="${itemName}" /></option>
</c:forEach>
</select>
<html:text property="clientName" />
ClientActionForm_
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
ActionErrors errors = new ActionErrors();
if (getclientName() == null || getclientName().length() < 1) {
errors.add("name", new ActionMessage("error.name.required"));
return errors;
Here is the process/page flow.
index.jsp is the first page which is loaded.
Link on index.jsp calls action="/client"
This pulls mapping from struts-config and calls testAction.java
This populates the arraylist and returns to the createClient.jsp page (mapping from struts-config.xml)
Now createClient.jsp page has two fields (dropdown list and textfield=clientName) and a submit button
if user clicks submit, clientActionForm is called and does not enter anything into clientName text field, error message is returned.
At this point, the drop down list in createClient.jsp is not populated and is returned as empty, even though the scope=session in struts-config.xml
Please provide some inputs on how can I handle this issue.
Thanks
Ashish

I think one solution would be instead of putting the list in the request, but it in your ActionForm.
Add a field to the ClientActionForm with getters and setters.
Then change your action.
ArrayList<String> arrList = new ArrayList<String>();
arrList.add("sports");
arrList.add("music");
arrList.add("test 1");
arrList.add("test2");
ClientActionForm frm = (ClientActionForm)form;
frm.setMyList(arrList);
return mapping.findForward(SUCCESS);

Similar Messages

  • Problem in sending drop down list value to jsp page showing  null value

    i am trying to send a drop down list value from client side to a jsp page but getting null value
    this is first page where i have accessed data from database and putted it in a drop down list
    <select name="sub">
         <%
         while(rs2.next())
         cat=rs2.getString(1);
         %><option value="<%=cat%>"><%=cat%></option><%
         }%></select>
    <input type="submit" value="Go"></input>
    now on submit i am going to another page
    where i want the selected value from drop down list to be printed
    i have used there
    <%
    String subject= request.getParameter( "sub.value" );
    out.println(subject);
    %>
    but it is printing null here what is the problem that i m facing
    thanx & reagrds
    sweety

    how to generate dynamically names for text boxes
    i am generating text boxes in while loop when selecting data from database
    while(rs1.next())
    name=rs1.getString(1);%>
    <tr>
    <td>1</td>
    <td><%out.println(name);
    //i am printing here stud_id a unique key and want to update records from following text boxes to particular stud_id
    %></td>
    <td><input type="text" name="????"></input></td>
    <td><input type="text" name="????"></input></td>
    <td><input type="text" name="????"></input></td>
    <td><input type="text" name="????"></input></td>
    </tr><%
    the structure is like
    stud_id | attended theory | conducted theory | ateended practical | conducted practical
    where attended theory, conducted theory............. are to be inputed manually for all students and then update in database
    so i am facing problem in generating names for textboxes how to do that
    so that those can be updated in database for particular student
    Thanx & Regards
    sweety

  • Drop down list issue

    Hi I am working on form which has a drop down box with 3 different values.
    Different textfield Item have to appear on the page according to the value selected in dropdown list.
    Problem is that I have to select each value from the dropdown list TWICE to make the corresponding textfield Item appear on the page.
    Can you please help me with this?
    I ran a javascript on "change" event and use Adobe Livecycle designer 8.
    I can post javascript I use, if you want.

    OK, I'm trying to make the above code work, but it's not. I have adapted it as posted below. By default I have my text field set to "invisible." My drop-down list and my text field are in the same subform as I want them to be side-by-side. Could this be my issue or am I just missing something really basic?
    switch (xfa.event.newText)
    case "New position":
    form1.ClassificationSection.ClassificationRequest.SubmitJobDescription_Note.presence = "visible";
    break;
    case "Establish a generic position":
    form1.ClassificationSection.ClassificationRequest.SubmitJobDescription_Note.presence = "invisible";
    break;
    case "Delete a position":
    form1.ClassificationSection.ClassificationRequest.SubmitJobDescription_Note.presence = "invisible";
    break;
    case "Review and update a position":
    form1.ClassificationSection.ClassificationRequest.SubmitJobDescription_Note.presence = "visible";
    break;
    case "Reclassify a position":
    form1.ClassificationSection.ClassificationRequest.SubmitJobDescription_Note.presence = "visible";
    break;

  • FME audio drop down list issue

    Currently FME only lists my recording devices (microphone, line in etc... I do not have stereo mix) and none of my playback devices (Default audio devices or any other), was it intentional that the only way to stream audio from my PC is via use of stereo mix or is my installation just messed up.
    Also windows 7 makes stereo mix irrelavent (listen to device feature) so it would be nice to have playback devices listed in the audio drop down list if the guys at adobe intentionaly made it so only recording devices were usable with the program.
    If this is just an issue with my install dont reply with "reinstall" I already have, so at this point to get it working if it is indeed just an issue on my end is to reformat and reinstall windows
    Also running windows 7 ultimate 64bit, sound card is the default card rolled in with the Striker Extreme mobo.

    You can use a line-in cable and provide the sound card output to the line-in input.

  • Using drop down list value in jsp with AJAX

    Hi All,
    I am having a jsp page , which contains a dropdown list.
    When user selects an item from the list, I've to pass this value to my java class to access other related information to be displayed on the same page without refreshing/submiting the page.
    Now the problem is, i am getting selected value in java script function but how to use this variable & pass it to java class.
    I googled a lot and found that AJAX could be used for it. Please suggest me that -
    1) Whether AJAX is the only approch ? I am affraid of it bcoz I hvn't work on it.
    2) Is there any other workaround by which i can use that value & call my java class method, without refreshing the page?
    3) If I've to use AJAX, plz help me if u've similar example. I went through the w3 scool, but not getting much idea.
    Kindly help me, the problem is very urgent with the strict timeline.
    Thanks & Regards,
    Sneha

    sneha wrote:
    1) Whether AJAX is the only approch ? I am affraid of it bcoz I hvn't work on it.Wait for it...
    2) Is there any other workaround by which i can use that value & call my java class method, without refreshing the page?Yes, Ajax!
    3) If I've to use AJAX, plz help me if u've similar example. I went through the w3 scool, but not getting much idea.Well then you'll have to do more work. Do a Google search, research more. Ajax is such a broadly discussed topic, you have to be very bad at your work if you cannot find decent resources for it in the context of your problem domain.
    To give you a hint, I suggest you look into JQuery. It is quite a popular Ajax javascript toolkit.

  • New Adobe DC works not with fillable Documents (Drop Down Lists) in iOS

    Hi, the new Adobe DC for iOS (iPad) has a big Problem. When you have a fillable Form with some Drop Down Fields it only works with the first Drop Down. Any other Drop Down will not work since you manualy restart the Adobe in the Task Manager. Please Fix that quick! It's not usable for my Company anymore!!!

    Hi together,
    i received a temporary sollution from Adobe to fix that Drop-Down List issue. It works ;-)
    Adobe wrote:
    Hi Adrian,
    Your sample form exhibits a bug in the latest release of Mobile Acrobat/Reader.  The catalyst for this bug is a drop down setting called “Commit selected value immediately”.  Because this setting is rarely used for Mobile forms (it is generally used when connecting to a backend or when you want your selection to immediately toggle something else in the form), it may have been overlooked during final testing.  Nevertheless, we are holding this bug in highest priority to be fixed in the next release of Mobile Acrobat/Reader.
    In the meantime, it may be possible to keep your forms usable while you wait for the next release. Some of your drop down fields use the “Commit selected value immediately” setting and some do not.  Looking at your form, it does not appear that this setting is necessary for any form logic (for example, I do not see any javascript or Actions associated with the fields that would mandate this setting). If the drop down fields that have this setting were modified to be like the other drop down fields that do not have this setting, I believe your form will become usable again.  I have done this for the sample form you sent and have attached it to this message. 
    Let me know if this solves your immediate problem.  And as mentioned, the bug has been triaged and is being addressed with the highest priority level to be included in the next release of Mobile Acrobat/Reader.

  • Issue populating drop-down lists on newly created instances.

    I have a drop-down list on the main page and another ddl on the flowed subform. I have js code that populates the support type ddl when a selection is made on the team ddl. My issue is when I use instanceManager.addInstance(1); The new instance doesn't populate with the selection. How do I get it to populate. most of my code; not the array is at http://pastebin.com/uM0ssT8v

    Can anyone help???
    I have a date field on my jsp form. I want to ensure
    that the date is entered correctly.
    To do this I have 3 drop down lists....year, month,
    date.
    How can I populate the date list when the user selects
    a month?
    e.g. user enters "Feb". Date list should only display
    numbers 1 to 28 or 1 to 29 if it is a leap year.
    Any idea's or suggestions???

  • JSP HTML parameter form to call report - Dependent  drop down list

    I have a report parameter form developed using HTML & JSP to call oracle reports6i.
    First parameter "STATES", Second Parameter "CITY"
    I have a master-detail relation betwen STATE & CITY table.
    I want the parameter form drop down lists dependant. ie if the user chang STATE value in the first drop down, the second drop down list CITY shoud
    change automatically.
    Please help
    Thanks
    Vimal

    Vimal,
    This is not functionality that's available in the Reports generated parameter form. In order to do this you'll need to build the parameter form yourself as a true HTML form and code the javascript to link the fields.
    Hope this helps,
    Danny

  • Getting problem in hiding drop down list in jsp pages

    Hi All,
    I have a jsp in which i created a tabbed panel & put 3 forms .
    1 of the form contains 3 drop dwom list & few text boxes.
    All 3 forms are inside <div> tags .
    Clicking on any one of the tab corresponding form is getting displayed with all its form fields hiding other 2 form fields.
    but problem is coming with 1 form having drop down list.
    all its field get hidden except these drop down list.
    i am using following script to hide other forms
    function showit(tab){
        if(tab == "tab1stuff"){
            document.getElementById('tab1stuff').style.zIndex="2";
            document.getElementById('tab2stuff').style.zIndex="1";
            document.getElementById('tab3stuff').style.zIndex="1";
              document.getElementById('tab4stuff').style.zIndex="1";
        else if(tab == "tab2stuff"){
            document.getElementById('tab2stuff').style.zIndex="2";
            document.getElementById('tab1stuff').style.zIndex="1";
            document.getElementById('tab3stuff').style.zIndex="1";
              document.getElementById('tab4stuff').style.zIndex="1";
        else if(tab == "tab3stuff"){
            document.getElementById('tab3stuff').style.zIndex="2";
            document.getElementById('tab1stuff').style.zIndex="1";
            document.getElementById('tab2stuff').style.zIndex="1";
              document.getElementById('tab4stuff').style.zIndex="1";
    }Plz help me in this regard.
    I used style.visible="false" but that is not working here.
    Thanks in advance.

    Thanks you very much.
    Now I am using javascript
    if(tab == "tab1stuff"){
            document.getElementById('tab1stuff').style.visibility="visible";
            document.getElementById('tab2stuff').style.visibility="hidden";
            document.getElementById('tab3stuff').style.visibility="hidden";
            document.getElementById('tab4stuff').style.visibility="hidden";
        } Its working ..Earliar it was PHP script.

  • How to display information from database using drop down list in JSP?

    Hi all.
    Like the tile above suggest, I'm having difficulty in obtaining the data as well as displaying them in a drop down list.
    For example: If i were to have the following in my database:
    SerialNo Food
    1 Bread
    2 Milk
    3 Butter
    The drop down list should look like the following:
    [Bread][\/]
    [Milk]
    [Butter]
    How do i go around coding it in JSP?
    Thanks in advance.
    C.K

    Hai Please try the following code
    You have to make some changes according to your system i am using
    MSSqlserver Driver change the class name and the connection string
    for your need
    <HTML>
    <HEAD>
    <%@ page language="java" import="java.sql.*"%>
    <LINK href="../theme/Master.css" rel="stylesheet" type="text/css">
    <TITLE>ListDrop.jsp</TITLE>
    <%!Connection con;
         %>
    </HEAD>
    <BODY>
    <select>
         <%
              try {
                   Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");\\Here you specify the Class Nale
                   con = DriverManager
                             .getConnection(
                                       "jdbc:microsoft:sqlserver://javaserver:1433;DatabaseName=karthi",
                                       "sa", "sa");\\here Connection string
                   ResultSet rs;
                   Statement st = con.createStatement();
                   rs = st.executeQuery("select SerialNo,Food from Foods");
                   while (rs.next()) {
    %>
         <option value='<%= rs.getString("SerialNo") %>'><%= rs.getString("Food")%></option>
         <%
              } catch (Exception e) {
                   e.printStackTrace();
    %>
    </select>
    </BODY>
    </HTML>

  • Drop-down lists, scrolling and IE 7 issue?

    I was using Captivate 3 prior to my work upgrading to
    Internet Explorer 7 and had no issues with capturing scrolling
    within a webpage and chosing an option on a drop-down list. I just
    recently started working on a new project and using IE 7.
    I went through my steps on using a drop-down list and
    scrolling through it to find an option. However, when I went in to
    edit the demonstration, the slide that showed the "selection" put
    the correct selection in the caption - however, the slide
    background image had somehow reverted the drop-down list to the top
    of the list rather than in the middle where the selection would
    have taken place.
    Has anyone else seen this?
    I went back did the same steps - but this time, I made sure
    to take an extra shot prior to clicking the option - so I had the
    correct screen showing for the lesson.
    Anyone else have any other issues going on with IE 7 and
    Captivate 3 that I should be aware of?
    Thanks.

    I have only been using Captivate for about a month now, but
    that is how it has always behaved for me...When you click and drag
    it starts the "Full Motion Recording". I have had mixed results
    with full motion so far. Scrolling up and down and zooming in and
    out of a page have been problematic. You can change these options,
    or turn off the full motion all together.
    Edit--Preferences--Recording--Full Motion Recording.
    BTW, I am using IE7 on a Vista machine so I cannot speak to
    the functionality prior to IE7.

  • HT1933 Following the instructions above, I'm constantly redirected to this help page rather than receiving any drop down list to select what my problem is. Are there any other ways to report issues with purchases?

    Following the instructions for reporting an issue with a purchase problem, when selecting "report a probelm", I am not provided with a drop down list, I am redirected to the help page instead.
    Is there any other way to report an issue where the app owner has taken the funds twice for the same product at literally the same time?

    To Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • Related Issue column in tracking list gets changed into drop down list in Infopath

    Hi All,
     i have created Tracking list in sharepoint 2010. which has column[Related issue - lookup for field in list[title] by default.
    this field will have a multiple selection check box,2 buttons [Add and remove] and text box[which show the items selected in check box].
    my issue is ,when i try to modify my list in Infopath. this column[Related issue] gets changed into drop down list item.Is is possible  to get the same [old format] back. if so pls guide me..
    I faced the same in Radio button,but i restored it by changing it into option button in Infopath
    V Jean

    Hi ,
    The
    multiple-selection list box control should be by design in InfoPath form, which is corresponding to the SharePoint "Related Issues" field, in my opinion, it cannot be converted to [old format] in InfoPath form, you may need to use SharePoint Designer 2010
    to customize your Issue Tracking list NewForm.aspx/EditForm.aspx per the way in the following article, then "Related Issues" field will still be the old format,
    http://www.cjvandyk.com/blog/Articles/How%20do%20I%20-%20Customize%20the%20NewForm.aspx%20or%20EditForm.aspx%20of%20my%20SharePoint%20list.aspx
    Thanks
    Daniel Yang
    TechNet Community Support

  • Dynamic drop down list in jsp

    Hi -
    I have written a piece of code to dynamically include data in the drop down list after querying the data base. I can print the values using out.print().. but they do not show up in the drop down list. Below is the code -
    Please lemme know the mistake i am committing. Thanks you!
    <form name="browse" method = "POST">
    <select name="uid">
    <%
    //out.write("before vec");
    unit.setCid(user.getCid());
         Vector unitNumbers = unit.getUnitNumbers();
         ListIterator iter1 = unitNumbers.listIterator();
              while ( iter1.hasNext() ){
                   Integer num = (Integer)iter1.next();
    //               out.print(num.intValue());
    //               out.print("Hellooooooooo");
    %>
    <options> <%= num.intValue() %>
    <% }
    %>
    </select>
    </form>

    The correct tag should be <option value="val">Val</option>, like this:
    <form name="browse" method = "POST">
      <select name="uid">
        <%
          unit.setCid(user.getCid());
          Vector unitNumbers = unit.getUnitNumbers();
          ListIterator iter1 = unitNumbers.listIterator();
          while ( iter1.hasNext() )
            Integer num = (Integer)iter1.next();
        %>
        <option value="<%= num.intValue() %>"><%= num.intValue() %></option>
        <% } %>
      </select>
    </form>

  • C5.5 Issue with color/colour in matching question drop down list

    Hi is there a way to change the colour of the letters that appear in the drop down lists for a matching question in 5.5?
    I'm using white text on a grey background for my quiz slides, which is nice and easy to read, but then in the preview the letters in the drop down appear as white text on a white background. I can't see a way to change the font in the drop down back to black (as it is on my editing view), without also changing the colour of the answer text.
    Is there a way to change this?
    I've just tried covering the lists over with a chunk of background image - so that the user doesn't even know they're there, but the quiz slide has ordered the image behind the lists.
    Failing there being a way to change the colour, is there a way to have a matching slide without a drop down list at all?
    Thanks for reading
    Lynn

    Hi Shekhar
    Thanks for the extra info - I'd tried changing the properties and using the object style manager before, but hadn't considered using them together.
    This time, I followed your advice and:
    I set the colour for 'Matching entries' to black in the object style manager
    Then went into each column 1 entry and set the text to white
    The result was white text in the column, with black in the list. Much better than before!
    However, when I changed the text in column 2 to white, the list entries became white as well.
    After a lot of experimentation, I've discovered that if you just select the text object and change the colour, you change all the text including the lettering and numbering of the answer - this changes the list colour.
    If you change the text in the answer by highlighting it, this doesn't affect the lettering/numbering, however it still changes the drop down
    To leave the drop down the right colour you need to change the answer colour by highlighting first, but, and the order is vital, you need to insert a space between the letter/number and the answer text first.
    So, the end result I have is that the column 1 text is the right colour, the column 2 text is the right colour and the text in the drop down is the right colour. Unfortunately the lettering for the column 2 answers has to stay the same  as the letters in the drop down list, so they don't show up brilliantly (black on a dark grey background), but it's a massive improvement on the invisible list I had before!
    Thanks again!
    Lynn

Maybe you are looking for

  • Is there any way to transfer non-itunes store music to your iTunes?

    I kind of killed my macbook, and it had to go to mac support and in order to make it happy and shiny again they had to wipe all of its memory. Now, I've restored the song purchased on itunes to my itunes, but 1. The iTunes/MacBook doesn't seem to be

  • Why can I not print postage on eBay with Firefox 4?

    I tried using 4 but my postage would not print in eBay so I went back to 3.6. I use windows xp. Any ideas? Thanks Lois

  • Is apple going to make a new ipod classic?

    i was wondering to but an old ipod classic or wait for a new one. But, is there going to be a new one?

  • Setting Page Items from SQL Query

    Hi, </br></br> I am using "SQL Query (PL/SQL function body returning SQL query)" for a report. In the body of the sql query, after calling a function, I have the following statement: </br></br> APEX_UTIL.SET_SESSION_STATE( p_name => 'P13_MESSAGE', p_

  • Using ABAP Proxies

    Hi all, I am trying to achieve the following scenario: Read a file from a specific directory and directly insert the records into the SAP table by using ABAP proxies. But during execution, I am getting the following error:   <?xml version="1.0" encod