// Path: src/java/connection/Config.java
// public class Config
// {
//     Connection con=null;
//     String url = "jdbc:mysql://localhost:3306/code_online_judge";
//     String user = "root";
//     String pass = "root";
//     //String pass = "panjasabd";
//     public Connection getcon()
//     {
//         try
//         {
//             Class.forName("com.mysql.jdbc.Driver");
//             con = DriverManager.getConnection(url,user,pass);
// 
//         }
//         catch(Exception e)
//         {
//           e.printStackTrace();
//         }
// 
//         return con;
//     }
// 
// }


import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
import connection.Config;
import javax.servlet.http.HttpSession;
import org.json.simple.JSONObject;
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author faridi
 */
public class checkdb extends HttpServlet {
     HttpSession session=null;
    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
     String username =(String) session.getAttribute("username");
     if(username == null)
               {
                    response.sendRedirect("login.jsp");
                }
    else{        
        try {
            String problemcode = (String)request.getParameter("q");
            String contestcode = (String)request.getParameter("c");
            String codefilename = (String)request.getParameter("code");
  
   /* =========================== user not registered : redirect to index page ====================*/
   
// Path: src/java/connection/Config.java
// public class Config
// {
//     Connection con=null;
//     String url = "jdbc:mysql://localhost:3306/code_online_judge";
//     String user = "root";
//     String pass = "root";
//     //String pass = "panjasabd";
//     public Connection getcon()
//     {
//         try
//         {
//             Class.forName("com.mysql.jdbc.Driver");
//             con = DriverManager.getConnection(url,user,pass);
// 
//         }
//         catch(Exception e)
//         {
//           e.printStackTrace();
//         }
// 
//         return con;
//     }
// 
// }


// Path: src/java/checkdb.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
import connection.Config;
import javax.servlet.http.HttpSession;
import org.json.simple.JSONObject;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author faridi
 */
public class checkdb extends HttpServlet {
     HttpSession session=null;
    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
     String username =(String) session.getAttribute("username");
     if(username == null)
               {
                    response.sendRedirect("login.jsp");
                }
    else{        
        try {
            String problemcode = (String)request.getParameter("q");
            String contestcode = (String)request.getParameter("c");
            String codefilename = (String)request.getParameter("code");
  
   /* =========================== user not registered : redirect to index page ====================*/
   
            Config c = new Config();