Trouble Installing python-pip in Ubuntu




Recently I was facing problem installing the pip in my ubuntu 16.04. After some research I found a solution which is as follow:
python-pip is in the universe repositories, therefore use the steps below:
Try this steps one by one
sudo apt-get install software-properties-common
sudo apt-add-repository universe
sudo apt-get update
sudo apt-get install python-pip

Simple Guess Number using Servlet

______________________________________________________________________________

HelloServlet.java
______________________________________________________________________________

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by yubraj on 11/6/16.
 */
@WebServlet(urlPatterns = {"/HelloServlet"})
public class HelloServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<body>");
        out.println("Hello World");
        out.println("</body>");
        out.println("</html>");
        out.flush();
        out.close();
    }
}

________________________________________________________________________________

LogonServlet.java
______________________________________________________________________________

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by yubraj on 11/6/16.
 */
@WebServlet(name = "LogonServlet", urlPatterns = {"/LogonServlet"})
public class LogonServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<body>");
        if(username.equals("user") && password.equals("pass")){
            out.print("Welcome user");
        }else {
            out.print("Wrong UserId or Password! Please try again");
            out.println("<form method=POST action=LogonServlet>");
            out.println("Username=<input type=text name=username> <br>");
            out.println("Password=<input type=text name=password>");
            out.println("<input type=submit value='Logon'>");
            out.println("</form>");
        }
        out.println("</body>");
        out.println("</html>");
        out.close();

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<body>");
        out.println("<form method=POST action=LogonServlet>");
        out.println("Username=<input type=text name=username> <br>");
        out.println("Password=<input type=text name=password>");
        out.println("<input type=submit value='Logon'>");
        out.println("</form>");
        out.println("</body>");
        out.println("</html>");
        out.close();
    }
}


______________________________________________________________________________

guessNumber.java
______________________________________________________________________________

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Random;

/**
 * Created by yubraj on 11/6/16.
 */
@WebServlet(name = "guessnumber", urlPatterns = {"/guessnumber"})
public class guessnumber extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession(true);
        PrintWriter out = response.getWriter();
        int num = Integer.parseInt(request.getParameter("number"));
        int randNumber = Integer.parseInt(session.getAttribute("randNum").toString());

        out.println("<html>" +
                "<head>" +
                "<title>Guess Number Game</title>" +
                "</head>" +
                "<body>");
        if(num == randNumber){
            out.println("Congratulation you won");
            out.println("<br><a href='/guessnumber'>Try Again</a>");
        }else if(num>randNumber){
            out.println("Number is too high. Try Again!");
            out.println("<br><a href='/guessnumber'>Try Again</a>");
        }else{
            out.println("Number is too low. Try Again!");
            out.println("<br><a href='/guessnumber'>Try Again</a>");
        }
        out.println("</body></html>");

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Random rand = new Random();
        int x = rand.nextInt(10);

        HttpSession session = request.getSession(true);
        session.setAttribute("randNum", x);

        PrintWriter out = response.getWriter();
        out.println("<html>" +
                "<head>" +
                    "<title>Guess Number Game</title>" +
                "</head>" +
                "<body>" +
                    "Enter the number between 1 and 10"+
                    "<form method=POST action=guessnumber>" +
                        "<input type=number name=number />" +
                        "<input type=SUBMIT value=Enter />" +
                    "</form>"+
                "</body></html>");
        System.out.println(x);
    }
}

------------------------------------------------------------------------------------------------------------
Web.xml
------------------------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
    <servlet>
        <servlet-name>HelloServlet</servlet-name>
        <servlet-class>HelloServlet</servlet-class>
    </servlet>
</web-app>

Simple Guess Number Game using JSP

<%@ page import="java.util.ArrayList" %>
<%--
  Created by IntelliJ IDEA.
  User: yubraj
  Date: 11/20/16
  Time: 4:27 PM
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>Number Guess System</title>
      <style>
          .error{ color: red; }
          .success { color: greenyellow; }
      </style>
  </head>
  <body>
    <h1>Hello world</h1>
    <%
        for(int i = 1; i<=10; i++){ %>
        <h5><%= +i%></h5>
    <% } %>
    <h1>Number Guess System</h1>
    <p>Guess Number within 1 and 10</p>

    <%
        final HttpSession       Sess = request.getSession();
        final boolean           JustStarted = Sess.isNew();
        final Integer           randomNumber;

        if(JustStarted){
                randomNumber = new Integer(new java.util.Random().nextInt(10));
                System.out.println("Random Number : " + randomNumber);
                Sess.setAttribute("number", randomNumber);
            } else {
                randomNumber = (Integer) Sess.getAttribute("number");
            }
    %>

    <%
        String inputText = request.getParameter("number");
        String errorMsg = null;
        boolean success = false;

        if(!JustStarted) {
            if (inputText != null && inputText.length() > 0) {
                int myNumber = Integer.parseInt(inputText);
                if (randomNumber != myNumber) {
                    if (myNumber > randomNumber)
                        errorMsg = "Number too large!";
                    else
                        errorMsg = "Number too Low!";
                } else {
                    errorMsg = "Congrats! you win";
                    success = true;
                }
            }
        }
    %>

    <div>
        <% if(errorMsg != null){ %>
            <p class="<% if(success){ %>
                        success
                       <% }else{ %>
                        error
                        <% } %>
                      ">
                <%= errorMsg %>
            </p>
        <% } %>
        <form method="post">
            <label for="number">Enter the Number : </label> <input type="tex" name="number" id="number" maxlength="3">
            <input type="submit" value="Submit">
        </form>
    </div>
  </body>
</html>