Home Answers Viewqa Java-Beginners how to set a value of dynamic number of drop down lists on a jsp page and access it value on another jsp page

 
 


purnima khurana
how to set a value of dynamic number of drop down lists on a jsp page and access it value on another jsp page
0 Answer(s)      8 months ago
Posted in : Java Beginners

actually i have to create dynamic number of drop down lists(depending upon number of books in that category) on jsp page pe v r creating these dynamic number of drop down lists having name rating1 ,rating2......number of buks in that category(and each drop down list has value from 0-4) n on nxt page v r accessing value using request.getparameter but on next page ven i try to print value of rating1.rating2..... it is coming null pls suggest any soln thanks in advance:) n i m also pasting both of my jsp files one setting values of drop down lists and other one accessing it in this jsp i m accessing values of rating1,rating2.... which are names given to drop down lists i hav make the line bold in which i m setting the values

<%-- 
    Document   : book_title
    Created on : Aug 20, 2012, 6:24:04 AM
    Author     : Pradeep
--%>

<%@page import= "java.sql.*"%>

<%

int count=0,count1=0,i=1,m;
    String isbn,s_no;
   String op;
 String subject = (String) session.getAttribute("subject");
 String userid = (String) session.getAttribute("userid");
 String updateString1;
 String category=request.getParameter("count1");
 session.setAttribute("category", category);
  //String buffer="<br/><b>BOOK_TITLE</b><select name='book_title'><option value='-1'>Select</option>";  
 try{
 Class.forName("com.mysql.jdbc.Driver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/recommender","root","purnima");
 ResultSet rs2,rs3;
 PreparedStatement pstmt = null;
 int updateQuery=0;
 Statement stmt = con.createStatement(); 
 //Statement stmt1 = con.createStatement(); 
 Statement stmt2 = con.createStatement(); 
 //Statement stmt3 = con.createStatement();
   System.out.println("Select book_title from book_info where subject='"+subject+"' AND CATEGORY='"+category+"'"); 
    rs2 = stmt.executeQuery("Select S_NO,ISBN,book_title from book_info where subject='"+subject+"' AND CATEGORY='"+category+"'");  
  %>
 <br/><b>
 <% out.print(" BOOKS TO BE RATED ARE:: \n"); %>
      </b><br/><br/> 
      <table> 
          <tr><td>
 <% while(rs2.next())
 {
     count1++;
 }
 //session.setAttribute("count1", count1);
    rs3 = stmt2.executeQuery("Select S_NO,ISBN,book_title from book_info where subject='"+subject+"' AND CATEGORY='"+category+"'");  

      while(rs3.next()){
  // buffer=buffer+"<option value='"+rs.getString("BOOK_TITLE")+"'>"+rs.getString("BOOK_TITLE")+"</option>";
    // s_no=rs3.getString("S_NO");
    // isbn=rs3.getString("ISBN");
     out.print(" "+rs3.getString("BOOK_TITLE")+" ");
     **op ="rating"+i; %>   
    <select name=op>** 
        <% System.out.println("op is "+op); i++;
            %>
    <option value="0">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option></select>
         </td></tr><br/></table>

  <% }  %>
  <center>
        <form name="" ACTION="recommendation.jsp"  METHOD=POST>
             <input type="submit" value="SUBMIT">
        </form>
   </center>

    <%
 //buffer=buffer+"</select>";  
 //response.getWriter().println(buffer); 
 }
 catch(Exception e){
     System.out.println(e);
 }
 %>

in this fragment of jsp page i m accessing values of rating1,rating2.... which are names given to drop down lists i have made the line bold in which i am accessing the values

     else
     {
        for(i=0;i<count1;i++)
        {
            **app=i+1;
            name=opname+app;
            val=request.getParameter(name);**
            if(!val.equals("0"))
            {   
        for(j=0;j<count2;j++)
        {
            if(book_isbn[i].equals(isbn[j]))//if user has changed the rating
            {
                flag=1;
                //st.executeUpdate("UPDATE TABLE USER_LIKING SET RATING = val WHERE USERID=userid and ISBN=isbn[j]");
                break;
            }
        }
        if(flag==0)//is user had never given rating for this particular book
        {
            String query = "INSERT INTO USER_LIKING(USER_ID,ISBN,RATING) VALUES(?,?,?)";
                        pstmt = con.prepareStatement(query);
                        pstmt.setString(1, userid);
                        pstmt.setString(2, book_isbn[i][0]);
                        pstmt.setString(3, val);
                        updateQuery = pstmt.executeUpdate();
                        if(updateQuery!=0)
                        System.out.println("The record has been successfully added to our database");
                }
            }
        }
    }
  }
  catch(Exception e){
     System.out.println(e);
 } 

%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Hello World!</h1>
    </body>
</html>

print("code sample");
View Answers









Related Pages:
how to set a value of dynamic number of drop down lists on a jsp page and access it value on another jsp page
how to set a value of dynamic number of drop down lists on a jsp page and access it value on another jsp page  actually i have to create dynamic... page pe v r creating these dynamic number of drop down lists having name rating1
Dependant & dynamic drop down list
Dependant & dynamic drop down list  I don't know this should be in this or AJAX forum. I have one dynamic drop down list from data base (working... on the values selected by user in first drop down list. How to achieve this ?   
dynamic drop down
dynamic drop down   I have created 2 drop downs in jsp.1... into the designation drop down (use jsp+javascript+servlet) reply soon   1..., the page should refresh quickly but keep all the correct info and then depending
how to retrieve the id value itself from the access database to drop down listbox in jsp
how to retrieve the id value itself from the access database to drop down... access database to drop down list box in jsp...plz send the code for that.....plz   <%@page import="java.sql.*"%> <select> <option value
Drop down and radio button value on edit action
Drop down and radio button value on edit action  HI, I have a title field and a payment type field for title i have used drop down with values... for text boxes..bt select default value for dropdown and radio button...How do
Dependant & dynamic drop down list - Follow up
Dependant & dynamic drop down list - Follow up  Thanks for your answer. As per your answer This will select only ONE row (country) from first drop... jsp for extract. How to achieve this ?   1)country.jsp: <%@page
JSP Dependent Drop Down Menu
JSP Dependent Drop Down Menu  Hey Guy/Gals! I need someone help to guide me in creating a drop down menu, where the first menu affects the second... guessing I will need to use JSP + AJAX to make this dynamic. Can anyone please
dynamic drop down list
dynamic drop down list  I want to create 2 drop down list, where it takes value from database and the two list are dependent..means if I select... on the value chosen from the previous. want code in javascript and jsp, Can you help
jsp drop down-- select Option
jsp drop down-- select Option  how to get drop down populated...) in database and try the following code: <%@page import="java.sql.*"%> <html>...;nbsp;</td> <select name="sel"><option value=""><---Select
i want to store dynamic number of value on one jsp and retrieve them on other.
i want to store dynamic number of value on one jsp and retrieve them on other... of result processing i have dynamic number of drop downs on a single page which... the value from each drop down in a different variable. i.e i want to create as many
Login With Drop Down
Login With Drop Down   Hi all, I am doing a project using JSP. My... box and then login to the page. I have a drop down list box with Customs... a drop down list consisting of Customs and Accounts. I have user accounts of both
jsp code for a drop down box to retrive value from database
jsp code for a drop down box to retrive value from database  my project needs to get the value from database in to the drop down box..... pls give me..."); while(rs.next()){ %> <option value="<%=rs.getString
Drop-down text selection in jsp/html
Drop-down text selection in jsp/html  Hi, I am trying to create JSP page where I have two drop-downs. There are two-sets of data - First set.... Now the first dropdown will have all the values. The second drop-down depends upon
dependent drop down box - JSP-Servlet
dependent drop down box  haloo sir Please give me the solution how to extract data from dependent drop down box with page refresh...; window.location.replace("http://localhost:8080/examples/jsp/dependentDropdown.jsp?id="+cid+"&&value
How to pass the value from controller to jsp page ?
How to pass the value from controller to jsp page ?  HI I need to pass the value from controller to jsp. I use the way like this Controller request.setAttribute("msg", "Successfully Login"); In jsp ${msg} and then i
Create dynamic page through JSP
Create dynamic page through JSP... how to create dynamic page. This code shows one by one record of student from...="#6E6E6E"><br>This is dynamic page that shows data<br>
jsp drop down without refresh - JSP-Servlet
jsp drop down without refresh  Sir I have tried two depenedent jsp dropdown in jsp page,But the probleam is when i select first drop down its... jsp same probleam also arise. Please tell me how to use the drop down without
how to use dropdown list in JSP and display value in same page
in the same page Value selected = C How can we do this in a JSP page...how to use dropdown list in JSP and display value in same page  I... one option the value must get displayed below it in the same page
how to display each arraylist value on new page in jsp
how to display each arraylist value on new page in jsp  hi!!!! i want to display each arraylist value on new page in jsp????? and also want to access...://www.roseindia.net/jsp/servlet-jsp-data-list.shtml
jsp login code ... when username , drop down box and password is correct
jsp login code ... when username , drop down box and password is correct ... value is correct.... the drop down box values should be retrieved from database... but its showing as wrong..... i dont know how to check the combo box selected value
Login With Drop Down, Having Departments in different table
the HTML page in such a way the I have a drop down list consisting of Customs... is to select the department from the drop down box and then login to the page. I... field.Now want to login to the page by selecting the drop down box. Suppose
displaying section in the jsp based on the sected value in drop down - Java Beginners
displaying section in the jsp based on the sected value in drop down   Hi friend, i have one problem in my jsp. i.e i have to display section on the jsp based on the selected value in the drop down list using java script code
session value not get in many jsp page.
session value not get in many jsp page.  I am using servlet to set...,response); and get session value on jsp page by follwing:- String user=(String... page its give null value
How to pass parameter through drop down list using session management in jsp??
How to pass parameter through drop down list using session management in jsp??  How to pass parameter through drop down list in the URL and access it on same jsp page using session management
Dependent drop down list
Dependent drop down list  hi,i am trying to design a form on which 2 dependent drop down list is used my code is successful but when i select class from first drop down list all the data get lossed means the value entered
Get values in drop down list
Get values in drop down list  Pls provide me jsp code to get values in drop down list from another table's field. my project has customer... in drop down box in front end..... pls provide me code.. thanx
want to insert values in drop down menu in struts1.3
want to insert values in drop down menu in struts1.3  I am using DynaValidatorForm.please help me with inserting values in color drop down menu. I...; <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:fmt="http
To get the value of more than one text box in an HTML page to a jsp page - JSP-Interview Questions
To get the value of more than one text box in an HTML page to a jsp page  An html file has a text box as To get the value of this text box in a JSP... the value of text boxes to a jsp page and how to access the same
Drop Down reload in IE
Drop Down reload in IE  Hi i was using two drop down box..One for Displaying date followed by another for Dispalying Month..If i Select/Change Month from the 2nd drop down then the 1st drop down ( which is date) automatically
Populate value into HTML page
Populate value into HTML page  Hi, How to populate values from one html page table to another html page..? Thanks
Pls provide me jsp code to get values in drop down list from another table's field....
Pls provide me jsp code to get values in drop down list from another table's field....  my project has customer registration and company registration... in customer registration page and should be shown in drop down box in front end
how to set time in jsp page
how to set time in jsp page   I need code for set the time in jsp code .iam using struts frame work back end oracle 10g ide is eclipse 6.0
Doubt in using combination of JSP page and Java class. - JSP-Servlet
be disabled from clicking. How to go about doing this in a "JSP Page using... it to another jsp page that i used to display those buttons with their name...Doubt in using combination of JSP page and Java class.   I've got
Drop down list from database
Drop down list from database  Hi, Can I know how do we get the drop down list from database? Eg: select country--select state--select district--so on.   1)country.jsp: <%@page import="java.sql.*"%> <html>
to access value of drop down value in beans when dropdown is populated using ajax
to access value of drop down value in beans when dropdown is populated using ajax  i want to access value of dropdown box in beans .. and this drop down was filled using ajax. plz help
how to change password into one jsp to another jsp
how to change password into one jsp to another jsp  i have two jsps in one jsp i give one password and confirm password, in another jsp i want change my password compare with 1st jsp how to write code please give me answer?  
How To Include Two Jsp page in another jsp page?
How To Include Two Jsp page in another jsp page?  I use following code to Include Two Jsp Page Header and footer <%@include file="header.jsp... in page How can i Display at correct position?   Please visit
Ajax drop down and textbox
Ajax drop down and textbox  hie frnds I have a dropdown menu in the 3... the dropdown box, the corresponding number of textboxes will get displayed on the browser...(this.value)"> <option value="none">Select</option>
how to delete the access database value in jsp
how to delete the access database value in jsp  i loaded my database data into the dropdown list box...now i want to delete the value..plz send the source code to delete the value in dropdown list box and also from database
how to delete the access database value in jsp
how to delete the access database value in jsp  i loaded my database data into the dropdown list box...now i want to delete the value..plz send the source code to delete the value in dropdown list box and also from database
How do i retain values in the drop down - Struts
How do i retain values in the drop down  Hi, I have a jsp page... with the drop down. My problem is whenever i do this the values in the drop down gets reset while the others in the text boxes don't. How do i retain the values
jsp page
jsp page  <%@ page language="java" contentType="text/html; charset... be a number"); return false; } if(price==null||price=="") { alert...)) { alert("Price should be a number"); return false; } if(thresholdLimit
Click on Page Refresh - JSP-Servlet
then you redirect this page to another page. 2)Second alternative is to set...Click on Page Refresh  hi ,i am working on jsp with mysql. i m facing a problem whenever i click on page refresh or f5 button, the value on form
Passing value in hyperlink - JSP-Servlet
Passing value in hyperlink  How to pass value in anchor tag or HTML link from one JSP page to another JSP page ?and how to retrieve values in another..., Retrive value from database Retrive data from database User   Hi
How to use 'for' loop in jsp page?
How to use 'for' loop in jsp page?   ... 'for' loop in jsp page. 'if' statement is used to test conditions while..._for_loop.jsp" in the application directory of tomcat server and run this jsp page
How to use 'if' statement in jsp page?
How to use 'if' statement in jsp page?  ... how to use 'if' statement in jsp page. This statement is used to test...; in the directory Tomcat-6.0.16/webapps/user/ and you can run this jsp page with url "http
how to add the calendar to the dynamic rows in html or jsp page - JSP-Servlet
how to add the calendar to the dynamic rows in html or jsp page   Hi Sir, i have 3 columns in my jsp page date of payment,amount recieved,no and i have 2 button in my jsp page ADD and delete button. when i click on add
inserting value - JSP-Servlet
the jsp inserting the value in the jsp after that i want these value inserted...;Inserting form data into database using JSP and ServletGiven code will illustrate you, how one can get data into database using JSP and ServletExample Code
Get form value in same page - JSP-Servlet
Get form value in same page  Hello friends, Can we get a form field value in the same to be processed in java coding... friend, For solving the problem visit to : http://roseindia.net/jsp/user
how to access JQuery array in jsp page?
how to access JQuery array in jsp page?  JQury Array: var elems =this.value; var arr = jQuery.makeArray(elems); How to get in jsp page

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.