<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
       
      </head>
<body bgcolor="white">
    <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=mechanical.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=Integer.parseInt(request.getParameter("mq"));
                int mmc=Integer.parseInt(request.getParameter("mc"));
                int mma=Integer.parseInt(request.getParameter("ma"));
                int llq=Integer.parseInt(request.getParameter("lq"));
                int llc=Integer.parseInt(request.getParameter("lc"));
                int lla=Integer.parseInt(request.getParameter("la"));
                int ssq=Integer.parseInt(request.getParameter("sq"));
                int ssc=Integer.parseInt(request.getParameter("sc"));
                int ssa=Integer.parseInt(request.getParameter("sa"));
                int ffq=Integer.parseInt(request.getParameter("fq"));
                int ffc=Integer.parseInt(request.getParameter("fc"));
                int ffa=Integer.parseInt(request.getParameter("fa"));
                int eeq=Integer.parseInt(request.getParameter("eq"));
                int eec=Integer.parseInt(request.getParameter("ec"));
                int eea=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=left>Max Marks : <th align=left>"+max);
            out.print("<th align=right>Date : <th align=left>"+dat+"</tr>");
           
            out.print("<tr><th align=left>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");
                
            int iid9=0,iid14=0,iid19=0,iid4=0,iid1=0,iid6=0,iid11=0,iid16=0,iid2=0,iid7=0,iid12=0,iid17=0;

            if(mmq>0)              
            {
                if(request.getParameter("id4")!=null)
                   iid4=Integer.parseInt(request.getParameter("id4")); 
                if(request.getParameter("id9")!=null)
                   iid9=Integer.parseInt(request.getParameter("id9"));
                if(request.getParameter("id14")!=null)
                   iid9=Integer.parseInt(request.getParameter("id14"));
                if(request.getParameter("id19")!=null)
                   iid9=Integer.parseInt(request.getParameter("id19"));
                 
               if(iid4>0 || iid9>0 || iid14>0 || iid19>0)
                {   
                  PreparedStatement pstmt1 = con.prepareStatement("select qname,opt1,opt2,opt3,opt4 from (select qname,opt1,opt2,opt3,opt4 from mqb where sec='English' order by dbms_random.value) where rownum <="+iid4+"  ");
                  ResultSet rs1= pstmt1.executeQuery();
                  PreparedStatement pstmt2 = con.prepareStatement("select qname,opt1,opt2,opt3,opt4 from (select qname,opt1,opt2,opt3,opt4 from mqb where sec='Aptitude' order by dbms_random.value) where rownum <="+iid9+"  ");
                  ResultSet rs2= pstmt2.executeQuery();
                  PreparedStatement pstmt3 = con.prepareStatement("select qname,opt1,opt2,opt3,opt4 from (select qname,opt1,opt2,opt3,opt4 from mqb where sec='G.K.' order by dbms_random.value) where rownum <="+iid14+"  ");
                  ResultSet rs3= pstmt3.executeQuery();
                  PreparedStatement pstmt4 = con.prepareStatement("select qname,opt1,opt2,opt3,opt4 from (select qname,opt1,opt2,opt3,opt4 from mqb where sec='Railway' order by dbms_random.value) where rownum <="+iid19+"  ");
                  ResultSet rs4= pstmt4.executeQuery();
                
                  out.print("<CENTER><TABLE width=800><TR><TD ALIGN=LEFT><h3>MULTIPLE CHOICES</h3></TD></TR></TABLE></CENTER>");
                  if(mma==0)
                  out.print("<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("<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>");
                  
                   if(iid4>0)
                   {  
                    out.println("<CENTER><h3>Section-English</h3></center>");                      
                    int x=1;
                    while(rs1.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> "+rs1.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 "+rs1.getString(2)+"&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 2) &nbsp&nbsp "+rs1.getString(3)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 3)&nbsp&nbsp "+rs1.getString(4)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 4)&nbsp&nbsp "+rs1.getString(5)+"</td></tr>");
                   
                     out.println("</table></CENTER><br>");
                     x++;

                    }
                 }
                 
                 if(iid9>0)
                 {   
                   int y=1;   
                   out.println("<CENTER><h3>Section-Aptitude</h3></center>");                                     
                 while(rs2.next())
                 {
                    
                 
                 out.println("<CENTER><h2><table width=800>");
                 out.println("<tr><td align=left width=20><h4>&nbsp&nbsp&nbsp&nbsp "+y+" &nbsp&nbsp</h4></td><td align=left><h4> "+rs2.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 "+rs2.getString(2)+"&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 2) &nbsp&nbsp "+rs2.getString(3)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 3)&nbsp&nbsp "+rs2.getString(4)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 4)&nbsp&nbsp "+rs2.getString(5)+"</td></tr>");
                 
                 out.println("</table></CENTER><br>");
                 y++;

                 }
                 }
                 if(iid14>0)
                 {  
                   out.println("<CENTER><h3>Section-G.K.</h3></center>");                      
                 int x=1;
                 while(rs3.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> "+rs3.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 "+rs3.getString(2)+"&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 2) &nbsp&nbsp "+rs3.getString(3)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 3)&nbsp&nbsp "+rs3.getString(4)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 4)&nbsp&nbsp "+rs3.getString(5)+"</td></tr>");
                 
                 out.println("</table></CENTER><br>");
                 x++;

                 }
                 }
                 
                 if(iid19>0)
                 {   
                   int y=1;   
                   out.println("<CENTER><h3>Section-Railways</h3></center>");                                     
                 while(rs2.next())
                 {
                    
                 
                 out.println("<CENTER><h2><table width=800>");
                 out.println("<tr><td align=left width=20><h4>&nbsp&nbsp&nbsp&nbsp "+y+" &nbsp&nbsp</h4></td><td align=left><h4> "+rs4.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 "+rs4.getString(2)+"&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 2) &nbsp&nbsp "+rs4.getString(3)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 3)&nbsp&nbsp "+rs4.getString(4)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 4)&nbsp&nbsp "+rs4.getString(5)+"</td></tr>");
                 
                 out.println("</table></CENTER><br>");
                 y++;

                 }
                 }
                }
               if(iid4==0 && iid9==0 && iid14==0 && iid19==0)
               {    
                  PreparedStatement pstmt1 = 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 rs1= pstmt1.executeQuery();
                  
                
                
                out.print("<CENTER><TABLE width=800><TR><TD ALIGN=LEFT><h3>MULTIPLE CHOICES</h3></TD></TR></TABLE></CENTER>");
                if(mma==0)
                  out.print("<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("<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>");
                  
                
                 int x=1;
                 while(rs1.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> "+rs1.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 "+rs1.getString(2)+"&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 2) &nbsp&nbsp "+rs1.getString(3)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 3)&nbsp&nbsp "+rs1.getString(4)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 4)&nbsp&nbsp "+rs1.getString(5)+"</td></tr>");
                 
                 out.println("</table></CENTER><br>");
                 x++;

                 }
               }
                
            }
            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>");
            int x=1;
            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)              
            {
                if(request.getParameter("id1")!=null)
                   iid1=Integer.parseInt(request.getParameter("id1")); 
                if(request.getParameter("id6")!=null)
                   iid6=Integer.parseInt(request.getParameter("id6"));
                if(request.getParameter("id11")!=null)
                   iid11=Integer.parseInt(request.getParameter("id11"));
                if(request.getParameter("id16")!=null)
                   iid16=Integer.parseInt(request.getParameter("id16"));
                 
               if(iid1>0 || iid6>0 || iid11>0 || iid16>0)
                {   
                  PreparedStatement pstmt1 = con.prepareStatement("select qname from (select qname from lqb where sec='English' order by dbms_random.value) where rownum <="+iid1+"  ");
                  ResultSet rs1= pstmt1.executeQuery();
                  PreparedStatement pstmt2 = con.prepareStatement("select qname from (select qname from lqb where sec='Aptitude' order by dbms_random.value) where rownum <="+iid6+"  ");
                  ResultSet rs2= pstmt2.executeQuery();
                   PreparedStatement pstmt3 = con.prepareStatement("select qname from (select qname from lqb where sec='G.K.' order by dbms_random.value) where rownum <="+iid11+"  ");
                  ResultSet rs3= pstmt3.executeQuery();
                  PreparedStatement pstmt4 = con.prepareStatement("select qname from (select qname from lqb where sec='Railway' order by dbms_random.value) where rownum <="+iid16+"  ");
                  ResultSet rs4= pstmt4.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("<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("<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>");
                  
                   if(iid1>0)
                   {  
                    out.println("<CENTER><h3>Section-English</h3></center>");                      
                    int x=1;
                    while(rs1.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> "+rs1.getString(1)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<h4></td></tr>");
                     out.println("</table></h2></CENTER>");
                     
                     x++;

                    }
                 }
                 
                 if(iid6>0)
                 {   
                   int y=1;   
                   out.println("<CENTER><h3>Section-Aptitude</h3></center>");                                     
                 while(rs2.next())
                 {
                    
                 
                 out.println("<CENTER><h2><table width=800>");
                 out.println("<tr><td align=left width=20><h4>&nbsp&nbsp&nbsp&nbsp "+y+" &nbsp&nbsp</h4></td><td align=left><h4> "+rs2.getString(1)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<h4></td></tr>");
                 out.println("</table></h2></CENTER>");
                 
                 y++;

                 }
                 }
                 if(iid11>0)
                 {  
                   out.println("<CENTER><h3>Section-G.K.</h3></center>");                      
                 int x=1;
                 while(rs3.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> "+rs3.getString(1)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<h4></td></tr>");
                 out.println("</table></h2></CENTER>");
                 
                 x++;

                 }
                 }
                 
                 if(iid16>0)
                 {   
                   int y=1;   
                   out.println("<CENTER><h3>Section-Railways</h3></center>");                                     
                 while(rs2.next())
                 {
                    
                 
                 out.println("<CENTER><h2><table width=800>");
                 out.println("<tr><td align=left width=20><h4>&nbsp&nbsp&nbsp&nbsp "+y+" &nbsp&nbsp</h4></td><td align=left><h4> "+rs4.getString(1)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<h4></td></tr>");
                 out.println("</table></h2></CENTER>");
                 
                 y++;

                 }
                 }
                }
               if(iid1==0 && iid6==0 && iid11==0 && iid16==0)
               {    
                  PreparedStatement pstmt1 = con.prepareStatement("select qname from (select qname from lqb order by dbms_random.value) where rownum ="+llq+" ");
                  ResultSet rs1= pstmt1.executeQuery();
                  
                
                
                out.print("<CENTER><TABLE width=800><TR><TD ALIGN=LEFT><h3>MULTIPLE CHOICES</h3></TD></TR></TABLE></CENTER>");
                if(lla==0)
                  out.print("<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 "+mmq+" &nbsp&nbsp X &nbsp&nbsp "+mmc+" &nbsp&nbsp = &nbsp&nbsp "+mmq*mmc+"</h3></td></tr></table></center>");
                else
                  out.print("<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>");
                  
                
                 int x=1;
                 while(rs1.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> "+rs1.getString(1)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<h4></td></tr>");
                 out.println("</table></h2></CENTER>");
                 
                 x++;

                 }
               }
                
            }
            if(ssq>0)              
            {
                if(request.getParameter("id2")!=null)
                   iid2=Integer.parseInt(request.getParameter("id2")); 
                if(request.getParameter("id7")!=null)
                   iid7=Integer.parseInt(request.getParameter("id7"));
                if(request.getParameter("id12")!=null)
                   iid12=Integer.parseInt(request.getParameter("id12"));
                if(request.getParameter("id17")!=null)
                   iid17=Integer.parseInt(request.getParameter("id17"));
                 
               if(iid2>0 || iid7>0 || iid12>0 || iid17>0)
                {   
                  PreparedStatement pstmt1 = con.prepareStatement("select qname from (select qname from sqb where sec='English' order by dbms_random.value) where rownum <="+iid2+"  ");
                  ResultSet rs1= pstmt1.executeQuery();
                  PreparedStatement pstmt2 = con.prepareStatement("select qname from (select qname from sqb where sec='Aptitude' order by dbms_random.value) where rownum <="+iid7+"  ");
                  ResultSet rs2= pstmt2.executeQuery();
                   PreparedStatement pstmt3 = con.prepareStatement("select qname from (select qname from sqb where sec='G.K.' order by dbms_random.value) where rownum <="+iid12+"  ");
                  ResultSet rs3= pstmt3.executeQuery();
                  PreparedStatement pstmt4 = con.prepareStatement("select qname from (select qname from sqb where sec='Railway' order by dbms_random.value) where rownum <="+iid17+"  ");
                  ResultSet rs4= pstmt4.executeQuery();
                
                  out.print("<CENTER><TABLE width=800><TR><TD ALIGN=LEFT><h3>DESCRIPTIVE(Short Answer Type)</h3></TD></TR></TABLE></CENTER>");
                  if(ssa==0)
                  out.print("<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&nbsp X &nbsp&nbsp "+ssc+" &nbsp&nbsp = &nbsp&nbsp "+ssq*ssc+"</h3></td></tr></table></center>");
                  else
                  out.print("<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>");
                  
                   if(iid2>0)
                   {  
                    out.println("<CENTER><h3>Section-English</h3></center>");                      
                    int x=1;
                    while(rs1.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> "+rs1.getString(1)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<h4></td></tr>");
                     out.println("</table></h2></CENTER>");
                     
                     x++;

                    }
                 }
                 
                 if(iid7>0)
                 {   
                   int y=1;   
                   out.println("<CENTER><h3>Section-Aptitude</h3></center>");                                     
                 while(rs2.next())
                 {
                    
                 
                 out.println("<CENTER><h2><table width=800>");
                 out.println("<tr><td align=left width=20><h4>&nbsp&nbsp&nbsp&nbsp "+y+" &nbsp&nbsp</h4></td><td align=left><h4> "+rs2.getString(1)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<h4></td></tr>");
                 out.println("</table></h2></CENTER>");
                 
                 y++;

                 }
                 }
                 if(iid12>0)
                 {  
                   out.println("<CENTER><h3>Section-G.K.</h3></center>");                      
                 int x=1;
                 while(rs3.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> "+rs3.getString(1)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<h4></td></tr>");
                 out.println("</table></h2></CENTER>");
                 
                 x++;

                 }
                 }
                 
                 if(iid17>0)
                 {   
                   int y=1;   
                   out.println("<CENTER><h3>Section-Railways</h3></center>");                                     
                 while(rs2.next())
                 {
                    
                 
                 out.println("<CENTER><h2><table width=800>");
                 out.println("<tr><td align=left width=20><h4>&nbsp&nbsp&nbsp&nbsp "+y+" &nbsp&nbsp</h4></td><td align=left><h4> "+rs4.getString(1)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<h4></td></tr>");
                 out.println("</table></h2></CENTER>");
                 
                 y++;

                 }
                 }
                }
               if(iid2==0 && iid7==0 && iid12==0 && iid17==0)
               {    
                  PreparedStatement pstmt1 = con.prepareStatement("select qname from (select qname from lqb order by dbms_random.value) where rownum ="+llq+" ");
                  ResultSet rs1= pstmt1.executeQuery();
                  
                
                
                out.print("<CENTER><TABLE width=800><TR><TD ALIGN=LEFT><h3>DESCRIPTIVE(Short Answer type)</h3></TD></TR></TABLE></CENTER>");
                if(ssa==0)
                  out.print("<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&nbsp X &nbsp&nbsp "+ssc+" &nbsp&nbsp = &nbsp&nbsp "+ssq*ssc+"</h3></td></tr></table></center>");
                else
                  out.print("<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>");
                  
                
                 int x=1;
                 while(rs1.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> "+rs1.getString(1)+" &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<h4></td></tr>");
                 out.println("</table></h2></CENTER>");
                 
                 x++;

                 }
               }
                
            }
            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>");
            
             int x=1;   
            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=PRINT name=Print  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");
   	    }
            catch(Exception e)
                    {
                out.print(e);
            }


          /*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>