<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>

      </head>
<body>
    <h2><font face=white></font></h2>



<%@page language="java" import="java.util.*,java.sql.* " contentType="text/html"%>

<%              
               response.setContentType("application/msword");
               response.setHeader("Content-disposition","attachment;filename=sree.doc");
                
                String tn= request.getParameter("tname");
                String post= request.getParameter("post");
                String scale= request.getParameter("scale");
                String dep= request.getParameter("dname");
                String div= request.getParameter("div");
                int max=Integer.parseInt(request.getParameter("tmarks"));
                String duration=request.getParameter("dur");
                String time=request.getParameter("tim");
                String dat=request.getParameter("date");
                int mmq=10;
                int mmc=1;
                int mma=0;//Integer.parseInt(request.getParameter("ma"));
                int llq=10;//Integer.parseInt(request.getParameter("lq"));
                int llc=10;//Integer.parseInt(request.getParameter("lc"));
                int lla=5;//Integer.parseInt(request.getParameter("la"));
                int ssq=10;//Integer.parseInt(request.getParameter("sq"));
                int ssc=3;//Integer.parseInt(request.getParameter("sc"));
                int ssa=5;//Integer.parseInt(request.getParameter("sa"));
                int ffq=10;//Integer.parseInt(request.getParameter("fq"));
                int ffc=1;//Integer.parseInt(request.getParameter("fc"));
                int ffa=0;//Integer.parseInt(request.getParameter("fa"));
                int eeq=10;//Integer.parseInt(request.getParameter("eq"));
                int eec=3;//Integer.parseInt(request.getParameter("ec"));
                int eea=5;//Integer.parseInt(request.getParameter("ea"));

                //String b= request.getParameter("op");

            out.print("<center><h3><b>QUESTION PAPER FOR SUITABILITY TEST FOR PROMOTION AS "+post+" IN SCALE Rs "+scale+"<br>");
            out.print("RS(RP) IN "+dep+" DEPARTMENT OF "+div+" DIVISION</b></center>");
            out.print("<br><br>");

            out.print("<center><table width=800>");
            out.print("<tr><th align=right>Max Marks : <th align=left>"+max);
            out.print("<th align=right>Date : <th align=left>"+dat+"</tr>");
            out.print("<tr><th align=right>Duration of Test : <th align=left>"+duration+"hrs ");
            out.print("<th align=right>Time of Examination : <th align=left>"+time+"</tr>");
            out.print("</table></center>");
            try {

             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

             Connection con=DriverManager.getConnection("jdbc:odbc:sree","sree","sree");
                //PreparedStatement pstm = con.prepareStatement("select qname,opt1,opt2,opt3,opt4 from mqb sample(50)");
                //ResultSet rs1= pstm.executeQuery();
            int x=1;

            if(mmq>0)
            {
                PreparedStatement pstmt = con.prepareStatement("select qname,opt1,opt2,opt3,opt4 from (select qname,opt1,opt2,opt3,opt4 from mqb order by dbms_random.value) where rownum <="+mmq+"");
                ResultSet rs= pstmt.executeQuery();
                out.print("<CENTER><TABLE width=800><TR><TD ALIGN=LEFT><h3>MULTIPLE CHOICES</h3></TD></TR></TABLE></CENTER>");
                if(mma==0)
                  out.print("<CENTER><table width=800><tr><td><h3>Answer all Questions. Each Question carries "+mmc+" marks &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp "+mmq+" &nbsp&nbsp X &nbsp&nbsp "+mmc+" &nbsp&nbsp = &nbsp&nbsp "+mmq*mmc+"</h3></td></tr></table></center>");
                else
                  out.print("<br><br><CENTER><table width=800><tr><td><h3>Answer any "+(mmq-mma)+" Questions. Each Question carries "+mmc+" marks &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp "+(mmq-mma)+"&nbsp&nbsp X &nbsp&nbsp "+mmc+" &nbsp&nbsp = &nbsp&nbsp "+(mmq-mma)*mmc+"</h3></td></tr></table></center>");



                while(rs.next())
            {
                 out.println("<CENTER><h2><table width=800>");
                 out.println("<tr><td align=left width=20><h4>&nbsp&nbsp&nbsp&nbsp "+x+". &nbsp&nbsp</h4></td><td align=left><h4>"+rs.getString(1)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<h4></td></tr>");
                 out.println("</table></h2></CENTER>");
                 out.println("<CENTER><table bgcolor=white width=800 >");
                 out.println("<tr><td align=left>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 1) &nbsp&nbsp "+rs.getString(2)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 2)&nbsp&nbsp "+rs.getString(3)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 3)&nbsp&nbsp "+rs.getString(4)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 4) &nbsp&nbsp "+rs.getString(5)+"</td></tr>");

                 out.println("</table></CENTER><br>");
                 x++;

             }
                out.print("<br>");

            }
            if(ffq>0)
            {
                PreparedStatement pstmt = con.prepareStatement("select qname from (select qname from fqb order by dbms_random.value) where rownum <="+ffq+"");
                ResultSet rs= pstmt.executeQuery();
                out.print("<CENTER><TABLE width=800><TR><TD ALIGN=LEFT><h3>FILL IN THE BLANKS</h3></TD></TR></TABLE></CENTER>");
                if(ffa==0)
                  out.print("<CENTER><table width=700><tr><td><h3>Answer all Questions. Each Question carries "+ffc+" marks &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp "+ffq+" &nbsp&nbsp X &nbsp&nbsp "+ffc+" &nbsp&nbsp = &nbsp&nbsp "+ffq*ffc+"</h3></td></tr></table></center>");
                else
                  out.print("<br><CENTER><table width=700><tr><td><h3>Answer any "+(ffq-ffa)+" Questions.Each Question carries "+ffc+" marks &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp "+(ffq-ffa)+" &nbsp&nbsp X &nbsp&nbsp "+ffc+" &nbsp&nbsp = &nbsp&nbsp "+(ffq-ffa)*ffc+"</h3></td></tr></table></center>");

            while(rs.next())
            {
                 out.println("<CENTER><h2><table width=800>");
                 out.println("<tr><td align=left width=20><h4>&nbsp&nbsp&nbsp&nbsp "+x+". &nbsp&nbsp</h4></td><td align=left><h4> "+rs.getString(1)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<h4></td></tr>");
                 out.println("</table></h2></CENTER>");
                 x++;
             }
                out.print("<br>");

            }
            if(llq>0)
            {
                PreparedStatement pstmt = con.prepareStatement("select qname from (select qname from lqb order by dbms_random.value) where rownum <="+llq+"");
                ResultSet rs= pstmt.executeQuery();
                out.print("<CENTER><TABLE width=800><TR><TD ALIGN=LEFT><h3>DESCRIPTIVE(Long Answer type)</h3></TD></TR></TABLE></CENTER>");
                if(lla==0)
                  out.print("<CENTER><table width=800><tr><td><h3>Answer all Questions. Each Question carries "+llc+" marks &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp "+llq+" &nbsp&nbsp X &nbsp&nbsp "+llc+" &nbsp&nbsp = &nbsp&nbsp "+llq*llc+"</h3></td></tr></table></center>");
                else
                  out.print("<br><CENTER><table width=800><tr><td><h3>Answer any "+(llq-lla)+" Questions.Each Question carries "+llc+" marks &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp "+(llq-lla)+" &nbsp&nbsp X &nbsp&nbsp "+llc+" &nbsp&nbsp = &nbsp&nbsp "+(llq-lla)*llc+"</h3></td></tr></table></center>");


            while(rs.next())
            {
                 out.println("<CENTER><h2><table width=800>");
                 out.println("<tr><td align=left width=20><h4>&nbsp&nbsp&nbsp&nbsp "+x+". &nbsp&nbsp</h4></td><td align=left><h4> "+rs.getString(1)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<h4></td></tr>");
                 out.println("</table></h2></CENTER>");

                 x++;
             }
                out.print("<br><br><br>");

            }
            if(ssq>0)
            {
                PreparedStatement pstmt = con.prepareStatement("select qname from (select qname from sqb order by dbms_random.value) where rownum <="+ssq+"");
                ResultSet rs= pstmt.executeQuery();
                out.print("<CENTER><TABLE width=800><TR><TD ALIGN=LEFT><h2>DESCRIPTIVE(Short Answer type)</h2></TD></TR></TABLE></CENTER>");
                if(ssa==0)
                  out.print("<CENTER><table width=800><tr><td><h3>Answer all Questions. Each Question carries "+ssc+" marks &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp "+ssq+" &nbsp&nbspX&nbsp&nbsp "+ssc+" &nbsp&nbsp = &nbsp&nbsp "+ssq*ssc+"</h3></td></tr></table></center>");
                else
                  out.print("<br><CENTER><table width=800><tr><td><h3>Answer any "+(ssq-ssa)+" Questions.Each Question carries "+ssc+" marks &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp "+(ssq-ssa)+" &nbsp&nbsp X &nbsp&nbsp "+ssc+" &nbsp&nbsp = &nbsp&nbsp "+(ssq-ssa)*ssc+"</h3></td></tr></table></center>");

            while(rs.next())
            {
                 out.println("<CENTER><h2><table width=800>");
                 out.println("<tr><td align=left width=20><h4>&nbsp&nbsp&nbsp&nbsp "+x+". &nbsp&nbsp</h4></td><td align=left><h4> "+rs.getString(1)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<h4></td></tr>");
                 out.println("</table></h2></CENTER>");
                 x++;
             }
                out.print("<br><br><br>");

            }
            if(eeq>0)
            {
                PreparedStatement pstmt = con.prepareStatement("select qname from (select qname from exp order by dbms_random.value) where rownum <="+eeq+"");
                ResultSet rs= pstmt.executeQuery();
                out.print("<CENTER><TABLE width=800><TR><TD ALIGN=LEFT><h3>EXPANSIONS</h3></TD></TR></TABLE></CENTER>");
                if(eea==0)
                  out.print("<CENTER><table width=800><tr><td><h3>Answer all Questions. Each Question carries "+eec+" marks &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp "+eeq+" &nbsp&nbsp X &nbsp&nbsp "+eec+" &nbsp&nbsp = &nbsp&nbsp "+eeq*eec+"</h3></td></tr></table></center>");
                else
                  out.print("<br><br><CENTER><table width=800><tr><td><h3>Answer any "+(eeq-eea)+" Questions.Each Question carries "+eec+" marks &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp "+(eeq-eea)+" &nbsp&nbsp X &nbsp&nbsp "+eec+" &nbsp&nbsp = &nbsp&nbsp "+(eeq-eea)*eec+"</h3></td></tr></table></center>");
            while(rs.next())
            {
                 out.println("<CENTER><h2><table width=800>");
                 out.println("<tr><td align=left width=20><h4>&nbsp&nbsp&nbsp&nbsp "+x+". &nbsp&nbsp</h4></td><td align=left><h4>"+rs.getString(1)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<h4></td></tr>");
                 out.println("</table></h2></CENTER>");
                 x++;
             }
                out.print("<br><br><br>");

            }
              out.println("<br><br><center><input type=submit value=CONFIRM name=CONFIRM  onclick=window.print()  /></center>");
              //out.println("<br><br><center><input type=submit value=save name=Print  onclick=window.browse()  /></center>");
              }
            catch(SQLException e)
                {
                out.println(e);
                }
            catch(ClassNotFoundException s)
           {
	        out.println("loaderror");
   	    }



          /*try {

               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

            Connection con=DriverManager.getConnection("jdbc:odbc:sree","sree","sree");


            if(s1==1 && s2==1)
               {
                PreparedStatement pstmt = con.prepareStatement("select * from mqb order by qid");

                ResultSet rs= pstmt.executeQuery();

            while(rs.next())
            {

                 out.println("<h2><table>");
                 out.println("<tr><td style=text-align:center; font-family:Comic Sans MS; font-size:20px; color:green;>"+rs.getInt(1)+"&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</td>");
                 out.println("<td align=left>"+rs.getString(2)+"</td></tr>");
                 out.println("</table></h2>");

                 out.println("<table>");
                 out.println("<tr><td>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp1)&nbsp&nbsp"+rs.getString(4)+"&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp2)&nbsp&nbsp"+rs.getString(5)+"&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp3)&nbsp&nbsp"+rs.getString(6)+"&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp4)&nbsp&nbsp"+rs.getString(7)+"</td></tr>");
                 out.println("<tr><td align=left>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspAns:&nbsp "+rs.getString(3)+"</td></tr>");
                 out.println("</table><br>");

             }

              out.println("<br><br><br>");
              out.println("<center><input type=submit value=PRINT name=Print  onclick=window.print()  /></center>");
             }
            }
            catch(SQLException e)
                {
                out.println(e);
                }
            catch(ClassNotFoundException s)
           {
	        out.println("loaderror");
   	    }*/

            %>
    </body>
 </html>