Help: List/Menus on jsp

can you please help me out on this one. I have questions table, answers table and student info table on my database.
<form METHOD="POST" name="form1">
here I want to get the number of subjects and store in (x).
<%
String[] subjects = {(String)rstry.getObject("subj1"),(String)rstry.getObject("subj2"), (String)rstry.getObject("subj3"), (String)rstry.getObject("subj4"),(String)rstry.getObject("subj5"), (String)rstry.getObject("subj6"), (String)rstry.getObject("subj7"), (String)rstry.getObject("subj8"), (String)rstry.getObject("subj9"), (String)rstry.getObject("subj10")};
for (int i=0; i < subjects.length; i++)
     if ( !subjects.equals(""))
               x = x + 1;
%>
here I'm getting the qestions
<%
     String[] questions = {(String) qsn.getObject("Q1"),qsn.getString("Q2"), qsn.getString("Q3"), qsn.getString("Q4"),qsn.getString("Q5"), qsn.getString("Q6"), qsn.getString("Q7"), qsn.getString("Q8"), qsn.getString("Q9"), qsn.getString("Q10")};
%>
here I create a table rows and columns are determined by the number of subjects(x) and number of questions.
Then depending on number of subjects I display the List/Menu to answer each question by subject.
after this I want to submit the answers i.e. List/menu to answers table but its submitting one answers i.e. List/menu 1.
how can i overcome this. I mean how can I get the value for the rest of List/menu
<table border= "0">
<tr bgcolor="red" height = "50">
<td>QUESTIONS</td>
<% for( int z = 0; z < x; z++){%>
<td bgcolor= >(<%= subjects[z]%>) </td>
<% }%>
<% for( int y = 0; y < 10; y++){%>
<tr>
<td bgcolor="#FF66CC"> <%= questions[y] %></td>
<% for( int a = 0; a < x; a++){%>
<td bgcolor="#66FF33"> <select name="select">
<option value="1">strongly disagree</option>
<option value="2">disagree</option>
<option value="3">agree</option>
<option value="4">strongly agree</option>
</select> </td>
<% }%>
</tr>
<% }%></tr></tr>
</table>
<p>Type your general comments here:
<textarea name="textarea"></textarea>
</p>
<p align="center">
<input type="submit" name="Submit" value="Submit" >
</p>
<input type="hidden" name="MM_insert" value="form1">
</form>
I hope you can help.
Thanks!!

it's quite normal not all of the feilds gets submitted. what you need is to create the table rows for answers in a loop and store them in an array (if you want to use the same name for all the answer select lists) in the page that you submit the info to.
here's a snippet:
this is where i create the <input>s for the form (note that all the names for the <input>s will be the same when the loop runs)
while(dba.next())
%>
<tr>
<td><%=dba.getString("ref_en")%><input type='hidden' name='refEn' value='<%=dba.getString("ref_en")%>'> / <%=dba.getString("ref_tr")%><input type='hidden' name='refTr' value='<%=dba.getString("ref_tr")%>'></td>
<td align='center'><input type='text' class='admin_body' name='lang0' size='20' maxlength='50' value='<%=dba.getString("lang_0")%>'></td>
<td align='center'><input type='text' class='admin_body' name='lang1' size='20' maxlength='50' value='<%=dba.getString("lang_1")%>'></td>
<td align='center'><input type='text' class='admin_body' name='lang2' size='20' maxlength='50' value='<%=dba.getString("lang_2")%>'></td>
<td align='center'><input type='text' class='admin_body' name='lang3' size='20' maxlength='50' value='<%=dba.getString("lang_3")%>'></td>
</tr>
<%
this is where i catch them
if(action.equals("updateKeywords"))
String[] refEn = request.getParameterValues("refEn"); // here we get parameters from the posting page into an array. obviously there are many "refEn" parameters coming from many <input> fields with the same name.
String[] refTr = request.getParameterValues("refTr");
String[] lang0 = request.getParameterValues("lang0");
String[] lang1 = request.getParameterValues("lang1");
String[] lang2 = request.getParameterValues("lang2");
String[] lang3 = request.getParameterValues("lang3");
hope this helps.
cem.

Similar Messages

  • How to build dynamic menus using JSP==Urgent==Please Help me

    Hello,
    I have exhausted searching on internet to find a book
    which tells how to build Dynmic menus in JSP.I dont want
    to use DHTML as this becomes complex as the menu categories
    are built using data from database.Is there any workaround in
    java to do this without DHTML or atleast sample code.
    can somebody help me in this regard.
    Thanks
    Jack

    Hello a.s.kumar,
    I would be greatful if you could send me the sample code.
    [email protected]
    we can't let MM Flash run away with the show can we. Javascript can do a decent job, but the underlying menu data is static.
    Cheers, Darren

  • Inserting items into List on a JSP

    I want to insert new items into a multiple select list from database
    on selecting an item from an existing list in a JSP.
    I am not sure how to do this.
    thanks

    This is basically performing partial page rendering. There is no way for HTML or JavaScript executing in a user's browser to communicate directly with Java or your database. You'll either have to "preseed" the values from the database into the HTML page using JavaScript, and then change the select list w/ JavaScript based on what the user selects (this is how it's usually done.)
    Or, you could do something like using a hidden IFrame as a data conduit to your JSP which sends JavaScript back to the browser and updates the select list with the new values. A little more tricky, and doesn't work w/ all browsers, but it would work better if the data in question can be arbitrarily large.
    Hope that helps.

  • How to filter results from 4 dynamic list menus depandant on how many of them are selected

    I have a search page with a form with 4 list menus and 1 submit that post the results to the results page. I can create a record set that either retrieves the correct data from my database if a selection is made from all four menus Or i can create the recordset if only 3 menus have a selection or the same for 2 menus and 1 menu. However i want the user to be able to make a selection from either 1, 2, 3 or all 4 of the menus and the exact data be retrieved. At present if i try to combine the recordset using AND and ORs the results are not specific enough, for example the 4 menus are Location, Type, Price & Style if a user selects from all 4 i only want to retrieve data that matches all 4 criteria, but at the same time if the user selects only 2 of the menus the i want it to retrieve data that matches specifically those 2 variables. I´m not actually sure if i should be creating a more advanced sql query of if its the php side of things that i need to look at. This is my first dynamic site so please be aware i´m still a learner where php and sql is concerned. Please can anyone help?  

    Hey there,
    Thanks for replying,
    I too am using Dreamweaver recordset, my local server is XAMPP ( apache php mysql), i´have pasted my sql recordset below to give an idea of what i´m trying to do, however this does not work as i´m trying to select the exact data based on 4 menus PRICE TYPE LOCATION and BEDS, and also want the search to work if the user only selects options from either 1, 2, 3 or 4 of the menus, with the code as it is if the user select only two options from 2 of the menus the results don´t just find (for example) all results for location AND price they find all results for the location varibale OR the price variable rather than a match for both, if you see what i mean?
    Any suggestions?  
    SELECT trueprice,`desc`, `propid`, `bathrooms`, `photo1`, locationtable.loc, typetable.style, bedtable.`number`
    FROM detailstable JOIN locationtable ON detailstable.location=locationtable.locid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid
    WHERE (location=varloc AND price = varprice AND type=vartype AND beds=varbed ) OR (price=varprice AND location=varloc AND type=vartype) OR  (price=varprice AND location=varloc AND beds=varbed) OR (price=varprice AND beds=varbed AND type=vartype) OR  ( location=varloc AND type=vartype AND beds=varbed) OR  (price=varprice AND location=varloc) OR (price=varprice AND type=vartype) OR (price=varprice AND beds=varbed) OR (type=vartype AND location=varloc) OR (type=vartype AND beds=beds) OR (location=varloc AND beds=varbed) OR (price = varprice OR beds=varbed OR type=vartype OR location=varloc)
    ORDER BY detailstable.trueprice ASC
    Look forward to receiving your thoughts,
    Linda
    Date: Wed, 21 Oct 2009 14:36:33 -0600
    From: [email protected]
    To: [email protected]
    Subject: how to filter results from 4 dynamic list menus depandant on how many of them are selected
    Hiya,
    I'm just doing my first dynamic site too, and am at a similar level to yourself.
    Can you give us more info re the site. What software, eg Dreamweaver etc are you using, and is your server using PHP or ASP etc?
    For what I've used, I amended the SQL side of things in the recordset in Dreamweaver. That way, you can test the SQL as you're setting up the recordset.
    Let me know how you're going on anyway
    Cheers
    Andy
    >

  • How do I make links from three list/menus on the same page?

    I've got three list/menus on one page. How do I make it so
    the choices in all three menus link to different pages?

    > When I insert the three form list/menus Dreamweaver does
    not allow me to turn
    > the lists into links. Javascript allows you to turn them
    into links. All I
    > want to know is what script to write.
    That is because you inserted a plain select form item.
    Insert a JUMPMENU and dw will do the coding for you.
    Open the F1 help, click search and type jumpmenu
    Alan
    Adobe Community Expert, dreamweaver
    http://www.adobe.com/communities/experts/

  • 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);

  • F4 Help list not showing values when a BEx 7x workbook is refreshed

    Hello All,
    Hope you are doing good. I have a very peculiar behaviour with F4 functionality of a variable while refreshing a workbook and thus requesting for your help.
    The workbook contains two queries. Both of these queries contains a common variable (of common characteristic).
    Info_Provider
    Query_Name
    Characteristic_Name
    Variable_Name
    Multi_Provider_1
    Query1
    Char1
    Var1
    Multi_Provider_2
    Query2
    Char1
    Var1
    When Query1 and Query2 are refreshed individually, the variable Var1 (basically a plant variable) shows the help list values.
    But when the workbook is refreshed (that's when both the queries gets executed together with a common variable screen) and
    upon clicking the help list of the variable Var1 doesn't show any values.
    Additional Info:
    1. Both the variables are configured to show data from Master table.
    2. The same set up works fine in 3x and also for other similar variables.
    Has anybody come across of this situation? If so, what is the issue and what was the solution?
    Pls share.
    Thank you.
    Lohith

    We recently had a similar issue with a variable... turns out the RSR_VARIABLE_F4_RESTRICT_BADI BADI was activated for this variable (and the code was no longer "valid" with the current situation).
    You may want to check whether you have that BADI activated.

  • Nothing happens when I click on any Help pulldown menus

    I have a G3 iMac and use a Seagate 160GB external hard drive. I've maxed out the memory on the iMac -- I only have 500Mb left. Yesterday, I noticed that none of the Help pulldown menus worked -- e.g., when I click on Mac Help or iPhoto help, nothing happens. Also, when I try to open iCal, nothing happens. Do I need to delete some files and create more room on the internal hard drive to open Mac Help and iCal?
    Any advice would be appreciated.

    Use Disk Utility to repair Permissions. You can find DU in Applications/Utilities.
    Click on your hard drive name at left, then the "Repair Permissions" button at bottom right. It will take a few minutes. This is normal.
    Run "Cron" maintenance scripts. This normally only happens between 3 and 5 AM, when the computer is powered on. But with help from Terminal they can be run anytime. (Terminal is also in the Utilities folder)
    In Terminal: (TYPE) sudo periodic daily weekly monthly (PRESS ENTER)
    You will be prompted for your admin password - you will not see the password as you type it. Press enter again. Cron scripts will take a couple of minutes to execute - be patient.
    Use Terminal to Update Prebinding (Optimize the System)
    (TYPE) sudo update_prebinding -root / - force (PRESS ENTER)
    Enter your Admin password as above.
    You should restart the iMac after running the above tasks.
    If you feel uncomfortable using Terminal, go to
    http://www.versiontracker.com/macosx
    and look for "Onyx" (freeware) or "Cocktail" (shareware) they do all the above, and a couple more things for you in a nice GUI package.

  • How to use List String in JSP page?

    Hello All,
    I am having problem using List<String> in my JSP page. Below is my JSP code.
    <%@ page import="java.util.*, java.io.*"%>
    <html>
    <body>
    <h1 align="center">Beer Recommendations JSP</h1>
    <p>
    <%
    List<String> beerBrands = (List<String>)request.getAttribute("styles");
    Iterator<String> it = beerBrands.iterator();
    while(it.hasNext()){
         out.print("<br>try: " + it.next());
    %>
    </body>
    </html>
    When I compile the above JSP code in Eclipse 3.4 (using JBoss 4.2 as my Application Server), I get the following Warning.
    Type safety: Unchecked cast from Enumeration to Enumeration<String>
    If I add the "@SuppressWarnings("unchecked")" to the code, Eclipse does not give any Error during compilation. But, at runtime, I get the following Error.
    org.apache.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 10 in the jsp file: /BeerAdvice.jsp
    Syntax error, annotations are only available if source level is 5.0
    7: <p>
    8:
    9: <%
    10: @SuppressWarnings("unchecked")
    11: List<String> beerBrands = (List<String>)request.getAttribute("styles");
    12: Iterator<String> it = beerBrands.iterator();
    13: while(it.hasNext()){
    An error occurred at line: 11 in the jsp file: /BeerAdvice.jsp
    The type List is not generic; it cannot be parameterized with arguments <String>
    8:
    9: <%
    10: @SuppressWarnings("unchecked")
    11: List<String> beerBrands = (List<String>)request.getAttribute("styles");
    12: Iterator<String> it = beerBrands.iterator();
    13: while(it.hasNext()){
    14:      out.print("<br>try: " + it.next());
    An error occurred at line: 11 in the jsp file: /BeerAdvice.jsp
    Syntax error, parameterized types are only available if source level is 5.0
    8:
    9: <%
    10: @SuppressWarnings("unchecked")
    11: List<String> beerBrands = (List<String>)request.getAttribute("styles");
    12: Iterator<String> it = beerBrands.iterator();
    13: while(it.hasNext()){
    14:      out.print("<br>try: " + it.next());
    Any help is very much appreciated.
    Thank you for your help.
    Thanks,
    Chubha

    Hi anotherAikman,
    Thank you for your help. I currently have the following version of the Java.
    {color:#800000}java version "1.6.0_17"
    Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
    Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)
    {color:#000000}{color:#000000}Does it mean I have Java SE Version 6 Update 17 and you are suggesting me to download the Java EE Version 6?{color} If this is correct, can you please let me know what difference does it make?
    I am now going to install the Java EE 6 and try this out.
    Thank you for your help.{color}
    {color:#000000}Thanks,
    Chubha{color}
    {color}

  • Using Lists in a JSP through usebean

    Hi,
    Needed a small help.
    I have a JSP where in i have to read a List and retrieve the Objects(Map objects) and get the values and display it in JSP.
    I would like to use the <usebean> attribute to avoid scriptlets.
    Please guide me through this.
    Any help is appreciated.
    Thanks in advance.

    Two solutions are there. Either you have to use JSTL. Perfect example for your query is here [http://www.java2s.com/Tutorial/Java/0380__JSTL/UseForEachtoLoopThroughArrayList.htm|http://www.java2s.com/Tutorial/Java/0380__JSTL/UseForEachtoLoopThroughArrayList.htm]
    OR write your own custom tag library.

  • Populating select list in a JSP with enumeration values

    I'm working on a JSP in which I need to populate a select list with enumeration values.
    Everytime I'm trying to insert these values (using enum.nextElement()) in a select box only the first enumerated value gets inserted correctly, the rest of the values shows up outside the select list. I would appreciated any help...thanks!!!

    I'm not exactly sure how your generating your list to begin with, however the following code will work:
    <form>
    <select>
    <%
         java.util.Vector v = new java.util.Vector();
         for(int i=0;i<12;i++){
              v.addElement(new Integer(i));
         java.util.Enumeration enum = v.elements();
         while(enum.hasMoreElements()){
         Object obj = enum.nextElement();
         out.println("<option name='"+obj+"'>"+obj+"</option>");
    %>
    </select>
    </form>Anthony
    BTW does anyone know why the greater than symbol never renders properly in these forums when text is encapsulated in the code tag?
    pre:
    >code:
    >

  • Creating drop down menus in JSP using custom tags

    Hi, i am working on a JSP which has custom tags for displaying menubar and menus, now i want to have these menus converted into drop down menus, and the submenus displayed onmouseover event. I am getting solutions with pure html page calling javascript functions.But i dont need this, i want the work done by my TagHandler class which sends the output to output stream, which in turn is transformed in to actual HTML by a XSLT embedded in my JSP.
    Please help as i am new to custom tags, and desperately in need of help.
    If possible give some sample code or useful links.
    I will be highly grateful.
    Thankx in advance

    that's fine, but the tag has to, ultimately, generate the HTML/Javascript stuff like you've already seen.

  • List box at jsp

    <select name="Action">
    <option value="Display">Display Info</option>
    <option value="Delete">Delete Info</option>
    <option value="Display">Update Info</option>
    </select>
    above is my option for my list box. how do i write a jsp coding to tell that i have selected the 1st option or so on. i wan my button react and direct to respective pages according to th eoption the user use.
    thanks!

    can anyone help me in his java script statement. if option 0 is selectef i wan the page to navigate to main.html. can u tel me the correct coding as mine is not working. thanks!!
    <SCRIPT>
    function Check(){
    if(document.ACTION.ActionSelect.selectedIndex==0){
    </SCRIPT>
    <INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="SUBMIT" onClick="main.html">
    <SCRIPT>
    </SCRIPT>
    <table>
    <tr>
    <td width="200">Transaction:</td>
    <td width="200">Sort by:</td>               
    </tr>
    <tr>
    <td width="200">
    <select name="ActionSelect" onBlur="Check();">
         <option value="Display">Display Info</option>
         <option value="Delete">Logout</option>
    </select>
    </td>
    <td width="200"><input type="text" name="sort"></td>
    </tr>
    </table>

  • 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.

  • Help with customised login JSP on SSO server

    Our customised version of the SSO login page JSP is required to access a database table in order to retrieve a dynamic message to display. This means we will need to create utility java classes in order to connect to the database and retrieve the information. We will also ideally need a data source on the SSO APP Server that we can reference in order to avoid hard-coding environment specific connection data.
    Can anyone help out on where we will need to install the utility classes and where the data source can be created in order for the login JSP to see them. Is there any other configuration we need to consider e.g. classpaths etc?
    The coding we are fine with, it is the actual "what goes where and don't forget to include this" that we are unsure of.

    Hello St***,
    Did you accomplished the cusomized SSO logon page with database access. If yes can you please provide met with some examples and instructions how to accomplish this.
    Regards,
    Dennis

Maybe you are looking for