Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2009
    Posts
    51
    Rep Power
    0

    Default Online Examination System

    i am developing an online examination system...I need to put one question in one page which is retrieved from the database ......please tell me how to do that i am using servlets and doing it




    the source code



    package jopack;

    import java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.Statement;
    import javax.annotation.Resource;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.sql.DataSource;


    public class joquiz extends HttpServlet {
    @Resource(name = "abedne")
    private DataSource abedne;



    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
    out.println("<form action=joresult2 method=post>");
    Connection con=abedne.getConnection("joexam","joexam");
    Statement st=con.createStatement();
    // out.println("st.executeQuery("+"Select ques from app.quiz where num=1"+")");
    String str="select * from joexam.quiz1 where num=";
    for(int i=1;i<=5;i++)
    {
    String str1=str+i;
    ResultSet rs=st.executeQuery(str1);
    if(rs.next())
    {
    String s1=rs.getString(2);
    String s2=rs.getString(3);
    String s3=rs.getString(4);
    String s4=rs.getString(5);
    String s5=rs.getString(6);
    out.println("<center>");
    out.println(i+"."+s1+"<br>");
    out.println("<input type=radio name=r"+i+" value=a>"+s2+"<br>");
    out.println("<input type=radio name=r"+i+" value=b>"+s3+"<br>");
    out.println("<input type=radio name=r"+i+" value=c>"+s4+"<br>");
    out.println("<input type=radio name=r"+i+" value=d>"+s5+"<br>");
    out.println("<input type=submit value=submit>");
    out.println("</center>");
    out.println("</form>");
    }
    // if(i<=2)
    // {
    // out.println("hello");
    // response.sendRedirect("joresult2");
    // }



    // out.println("Hello");
    }
    }



    catch(Exception e)
    {
    out.println(e);
    }
    finally {
    out.close();
    }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
    * Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    * @throws ServletException if a servlet-specific error occurs
    * @throws IOException if an I/O error occurs
    */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    }

    /**
    * Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    * @throws ServletException if a servlet-specific error occurs
    * @throws IOException if an I/O error occurs
    */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    }

    /**
    * Returns a short description of the servlet.
    * @return a String containing servlet description
    */
    @Override
    public String getServletInfo() {
    return "Short description";
    }// </editor-fold>

    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,266
    Rep Power
    25

    Default

    Do you have a template or sample of the HTML you want to generate in the servlet?

  3. #3
    Join Date
    Mar 2009
    Posts
    51
    Rep Power
    0

    Default

    i am not using html coding for any thing...only for my login page i am using html coding but for the other all i am using servlet pages

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,266
    Rep Power
    25

    Default

    What do you display to the user in his browser? What language is it written in?

  5. #5
    Join Date
    Mar 2009
    Posts
    51
    Rep Power
    0

    Default

    its written in java using servlets...I display the questions for the user ...along with the options

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,266
    Rep Power
    25

    Default

    Does the user view your pages with a browser or do you have an app that the user uses to see the output from your servlets?

    If a browser is used, What do you display to the user in the browser?

  7. #7
    Join Date
    Mar 2009
    Posts
    51
    Rep Power
    0

    Default

    the user uses the browser only

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,266
    Rep Power
    25

    Default

    If the user only uses a browser, what does the browser read and use to display your pages?
    I bet it's HTML.
    If it's not HTML, what is it?


    The Following from you code looks like it builds an HTML statement to send to the browser:
    <input type=radio name=r"+i+" value=a>"+s2+"<br>

Similar Threads

  1. Replies: 4
    Last Post: 01-13-2011, 05:30 PM
  2. Online examination system
    By jyothi.priyanka in forum New To Java
    Replies: 3
    Last Post: 05-26-2010, 06:28 PM
  3. help Online exam system
    By langkhach_codon in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-29-2010, 07:25 AM
  4. Everlong Online
    By Afide in forum Jobs Offered
    Replies: 3
    Last Post: 05-03-2009, 07:02 AM
  5. building a complete online evaluation system
    By pmminov in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 04-07-2009, 09:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •