#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    India
    Posts
    7
    Rep Power
    0

    Question Urgent: JSP: Evaluating a questionnaire form


    Hi
    I am creating this website in JSP and am stuck at a really silly problem. One of the pages requires me to read from a database of questions with 4 options each in the form of radio buttons. When the user presses submit...depending on the option chosen for each question, the questionnaire is evaluated.

    can read from the database and display the questions with the radio buttoned choices but I am confised as to how I shall evaluate this form. Do I have to use vectors? if so please advise how

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    No es importante
    Posts
    2,065
    Rep Power
    14
    You may be able to use a simple if { ... } else if {...} statement to evaluate the values.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    India
    Posts
    7
    Rep Power
    0
    Hi

    Even if i do use if and elseif to check, do I have to keep calling back the same JSP page (in which the questions are displayed) each time to do so?

    Also, is there a way that I can just declare each JSP one at a time? i.e. keep calling back the same page each time the user presses submit and then check the values?

    Here is a snippet of the code
    <HTML>
    <HEAD>
    <TITLE> Test1 Sample </TITLE>

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

    </HEAD>

    <body bgcolor="#FFFFFF">

    <%
    //Declarations
    Statement stmt;
    ResultSet rs;
    int i = 0;

    //Creating Database Instanse
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection Conn = DriverManager.getConnection("jdbcdbc:Tests");

    //Creating the Connection Statement
    stmt = Conn.createStatement();
    String query = "Select * from Test1";
    rs = stmt.executeQuery(query);
    while(rs.next())
    {
    String No = rs.getString("Question_number");
    String questionValue = rs.getString("Question");
    String op1 = rs.getString("Option_1");
    String op2 = rs.getString("Option_2");
    String op3 = rs.getString("Option_3");
    String op4 = rs.getString("Option_4");
    String answerValue = rs.getString("Correct_ans");
    int scoreValue = rs.getInt("Score");

    %>

    <Form method="POST" action="Analyse_test.jsp">

    <%= No %>.&nbsp;&nbsp;<%= questionValue%>
    <P align="left"><input type="radio" value="opt1" checked name="domain" ><%= op1 %>
    <P align="left"><input type="radio" value="opt2" checked name="domain" ><%= op2 %>
    <P align="left"><input type="radio" value="opt3" checked name="domain" ><%= op3 %>
    <P align="left"><input type="radio" value="opt4" checked name="domain" ><%= op4 %>

    <HR>

    <% } %>

    <P align="center">
    <input type="submit" value="Submit" name="B1">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
    <input type="reset" value="Reset" name="B2">

    </Form>

    </body>
    </html>


    This code simply displays the stuff......i need to add the checks
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    No es importante
    Posts
    2,065
    Rep Power
    14
    Have you tried using a bean that does this evaulation for you and using that bean where needed?
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    India
    Posts
    7
    Rep Power
    0
    Hi

    I did try to use a bean for this but I really would not know how to implement it...cuz each time i tried using the bean, it would not evaluate it

    Any ideas on the logic I would be using here?

    Thanks
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    No es importante
    Posts
    2,065
    Rep Power
    14
    Pass an array containing the values, return an array containing the evaulated information.

IMN logo majestic logo threadwatch logo seochat tools logo