im currently having an intense problem.
I cant seem to be able to create individual sessions for my clients who are using my servlet.
The key point of my servlet is that it provides a diffie hellman key exchange to individual sessions. That is working as intended , however when another user concurrently pushes the add token button. The previous values that were generated will be overwritten , so my server is limited to serving only one person at a time.
How do i create multiple sessions for my clients using my diffie hellman servlet? Thanks in advance.
Below is my code snippet.
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    HttpSession session = request.getSession(false);
    if(null == request.getRequestedSessionId())
    {
        //create new session
        System.out.println("No session id found , generating a new session ID");
        session = request.getSession(true);
        System.out.println("session id generated is "+session.getId());
        @SuppressWarnings("deprecation")
        String encodedURL = response.encodeUrl("/MyServletProject/DHServlet");
        System.out.println("res.encodeURL(\"/DHServlet\");="+encodedURL);
        response.sendRedirect(encodedURL);
        return;
    }else
    {
        System.out.println("session id = "+request.getRequestedSessionId());
        System.out.println("no redirect required");
    }
    processRequest(request,response);
}
My diffie hellman Key Exchange
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
   // PrintWriter out2=response.getWriter();
    DH getDH = new DH();
    try {
        System.out.println("Session id requested is "+request.getRequestedSessionId());
        long pValue = getDH.getSafePrime();
        long gValue = getDH.getGenValue(pValue);
        System.out.println("pValue is "+pValue);
        System.out.println("gValue us "+gValue);
        long serverSK = getDH.generateSKA();
        BigInteger safePrimeValue = BigInteger.valueOf(pValue);
        BigInteger generatorValue = BigInteger.valueOf(gValue);
        System.out.println("the safe Prime is "+safePrimeValue);
        System.out.println("the generator value is "+generatorValue);
        BigInteger serverPK = getDH.generatePkB(generatorValue, safePrimeValue, serverSK);
   // System.out.println(publicKeyFromClient);
    String getTimeOnServer = Time.getTime();
    String SPValue = safePrimeValue.toString();
    String genValue = generatorValue.toString();
    String sPublicKey = serverPK.toString();
   // long pkFromClient = Long.parseLong(publicKeyFromClient);
    //BigInteger pkC = BigInteger.valueOf(pkFromClient);
   System.out.println("the erver public key is "+sPublicKey);
   out.print("1"+":"+getTimeOnServer+":"+genValue+":"+SPValue+":"+sPublicKey);
   pkClient=sPublicKey.toString();
   SpValue = SPValue.toString();
   sCValue=Long.toString(serverSK);
    } finally {            
        out.close();
    }
}
