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 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 Tutorials/Questions & Answers:
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
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
Advertisements
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... changed the jsp as again the msg didn't see. when i set the controller
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
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...: (adsbygoogle = window.adsbygoogle || []).push({}); http://www.roseindia.net/jsp
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
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 code for that ..... tan q   1)login.jsp: <html> <script>
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:- (adsbygoogle...)session.getAttribute("user"); this is work but when this code is use in other jsp page its give
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
how to show effect (visual) on jsp page using value from database
how to show effect (visual) on jsp page using value from database  I... i want is when the value in booking status is "booked" then the pictures shown as seats should be displayed red. when the value in booking status
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 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 (adsbygoogle = window.adsbygoogle || []).push({}); How
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
code for insert the value from jsp to access database
code for insert the value from jsp to access database  code for insert the value from jsp to access database
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
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
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 save value in JSP
2012-12-12 save i want to save dis value jsp to action ...how can i get all value ..and store..how can its values goes ... (adsbygoogle...How to save value in JSP  Employee Name Time-IN Time-OUT
how to get the checkbox value in jsp
how to get the checkbox value in jsp  how to get the checkbox value in jsp?   JSP CheckBox Example - how to get the checkbox value in jsp
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
retrive the data from access database to drop down list box in jsp
retrive the data from access database to drop down list box in jsp  hai, im new to jsp now im using the jsp along with access database.in table i load all the data's i need to retrive the data from database to dropdown list box
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... Tomcat-6.0.16/webapps/user/ and run this jsp page with following url in address bar
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.....bt select default value for dropdown and radio button...How do i get the value
how to insert the bulk data into the data base from the table of jsp page to another jsp page
how to insert the bulk data into the data base from the table of jsp page to another jsp page  pls help i'm doing the project called centralized... and i have to insert the mark for n number student in the table i don't how
calling one jsp from another jsp page
calling one jsp from another jsp page  need coding for calling one jsp from another jsp including the xml file.Its urgent
How to change the value of a variable which is set in jsp (by jstl method) by calling the function from js?
How to change the value of a variable which is set in jsp (by jstl method) by calling the function from js?  How to change the value of a variable... the value in jsp by using jstl method for eg:'<'c:set var="name1" value="Add User
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 give the value - JSP-Servlet
How to give the value   How to give the value in following query.. "select * from studentinformation where studentid = '?'"; How to give the value into question mark?...  Hi Friend, Try the following code
use struts 1.0 to view sql table value on JSP page
use struts 1.0 to view sql table value on JSP page  Here i am using struts 1.0 to view my sql table values on jsp page. But the problem is when i append the value in bean then i find the last row of table is shown repetedly. Any
use struts 1.0 to view sql table value on JSP page
use struts 1.0 to view sql table value on JSP page  Here i am using struts 1.0 to view my sql table values on jsp page. But the problem is when i append the value in bean then i find the last row of table is shown repetedly. Any
how to assign javascript variable value to a jsp variable
how to assign javascript variable value to a jsp variable  how to assign javascript variable value to a jsp variable
JSP Value to JavaScript
that accepts the value from the jsp page.  Understand with ExampleADS_TO_REPLACE_1... have create a function addition() which takes the value from the jsp page. When... JSP Value to JavaScript   
Loading a jsp page (with record from database) from another jsp page
Loading a jsp page (with record from database) from another jsp page  Suppose I have two jsp pages Search.jsp and Getdata.jsp. There are two fields... as Getdata.jsp will be loaded, it will show the first record. How can I do
Insert value of dynamic generated text box in jsp using javascript
Insert value of dynamic generated text box in jsp using javascript  hello sir , i want to generate dynamic text box at run time and i did that using... reloading the page what i want is i can insert the multiple columns value generated
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
How to set the pdfptable as pdf page header when generating the pdf from jsp page. - JSP-Servlet
How to set the pdfptable as pdf page header when generating the pdf from jsp page.  how to set the pdfptable column headers as a header of the documet.i need to display the column headers for every pdf page if pdf documt is 20
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
calling one jap page from another jsp page
calling one jap page from another jsp page  i created a button in one jsp page i need to call another jsp page as an action to that button. so how can i call.. plz any one explain. its urgent
Passing Parameters to Another JSP Page
Passing Parameters to Another JSP Page      By using the include action we can pass the parameters to another jsp page... introduce a new request parameter when calling a jsp page. This param tag can
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
jsp drop down-- select Option
jsp drop down-- select Option  how to get drop down populated...) in database and try the following code:ADS_TO_REPLACE_1 <%@page import="java.sql.... a country:</b>&nbsp;</td> <select name="sel"><option value
Problem passing a value from one jsp to another using href
Problem passing a value from one jsp to another using href  first page.jsp <a href="common.jsp?param=<%l.get(k).parentname%>">... = window.adsbygoogle || []).push({}); but attr return a null value
Problem passing a value from one jsp to another using href
Problem passing a value from one jsp to another using href  first page.jsp <a href="common.jsp?param=<%l.get(k).parentname%>">... = window.adsbygoogle || []).push({}); but attr return a null value
displaying output on web page immediately whent the jsp buffer size is full. And how to set jsp buffer size in bytes
displaying output on web page immediately whent the jsp buffer size is full. And how to set jsp buffer size in bytes  Here is my requirement, I have to display output on the browser after jsp buffer is full. And I have to set
problem of static in jsp page by multiple user access
from my jsp page , ths page can access by more number of users .every user...problem of static in jsp page by multiple user access  hi , i am... by submitting n number of users. i want to this singleton class should be act
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
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  I am using a single jsp form.. i did not get from another form.. i do not use 2 jsp form.. all.... Note: I am using only this jsp form.. i do not use

Ads