Vishnu Khatri built the All Bank Balance Check app as a Free app. This SERVICE is provided by Vishnu Khatri at no cost and is intended for use as is. This page is used to inform visitors regarding my policies Read More …
Category: Programming
Indian Rupee Photo Frame Privacy Policy
Vishnu Khatri built the Indian Rupee Photo Frame app as a Free app. This SERVICE is provided by Vishnu Khatri at no cost and is intended for use as is. Vishnu Khatri built the Kabir Amritvani Audio app as a Read More …
Sunderkand in Hindi Privacy Policy
Vishnu Khatri built the Sunderkand in Hindi app as a Free app. This SERVICE is provided by Vishnu Khatri at no cost and is intended for use as is. This page is used to inform visitors regarding my policies with Read More …
Privacy Policy “Learn HTML5 Programming”
General This app is developed by Ajay Khatri. Privacy Policy (“Policy”) describes how information obtained from users is collected, used and disclosed. By using this, you agree that your personal information will be handled as described in this Policy. Information Read More …
Java Packages Example
1 2 3 4 5 6 7 8 9 10 11 12 13 |
//save as Simple.java package mypack.a1.a2; public class Simple{ public static void main(String args[]){ System.out.println("Welcome to package"); } } //Compile //javac -d . Simple.java //Run //java mypack.a1.a2.Simple |
Android Reference List
ADK: Android Development Kit, What people use to develop anything for the Android such as APPs and ROM’s adb: Android Debug Bridge, a command-line debugging application included with the SDK. It provides tools to browse the device, copy tools on the device, & forward ports for debugging. If you are developing in Eclipse using the ADT Plugin, adb is Read More …
JSP – File Uploading
Import two jar file first (Unzip and add both jar files) Download Zar Files jar files zip Create html page index.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<!DOCTYPE html> <html> <head> <title>File Uploading Form</title> </head> <body> <h3>File Upload:</h3> Select a file to upload: <br /> <form action = "UploadFile.jsp" method = "post" enctype = "multipart/form-data"> <input type = "file" name = "file" size = "50" /> <br /> <input type = "submit" value = "Upload File" /> </form> </body> </html> |
Create UploadFile.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
<%-- Document : UploadFile Created on : Apr 10, 2018, 3:57:15 PM Author : Admin --%> <%@page import="java.io.File"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@ page import = "java.io.*,java.util.*, javax.servlet.*" %> <%@ page import = "javax.servlet.http.*" %> <%@ page import = "org.apache.commons.fileupload.*" %> <%@ page import = "org.apache.commons.fileupload.disk.*" %> <%@ page import = "org.apache.commons.fileupload.servlet.*" %> <%@ page import = "org.apache.commons.io.output.*" %> <% File file ; int maxFileSize = 5000 * 1024; int maxMemSize = 5000 * 1024; ServletContext context = pageContext.getServletContext(); String filePath = context.getInitParameter("file-upload"); // Verify the content type String contentType = request.getContentType(); if ((contentType.indexOf("multipart/form-data") >= 0)) { DiskFileItemFactory factory = new DiskFileItemFactory(); // maximum size that will be stored in memory factory.setSizeThreshold(maxMemSize); // Location to save data that is larger than maxMemSize. factory.setRepository(new File("c:\\tempp")); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); // maximum file size to be uploaded. upload.setSizeMax( maxFileSize ); try { // Parse the request to get file items. List fileItems = upload.parseRequest(request); // Process the uploaded file items Iterator i = fileItems.iterator(); out.println("<html>"); out.println("<head>"); out.println("<title>JSP File upload</title>"); out.println("</head>"); out.println("<body>"); while ( i.hasNext () ) { FileItem fi = (FileItem)i.next(); if ( !fi.isFormField () ) { // Get the uploaded file parameters String fieldName = fi.getFieldName(); String fileName = fi.getName(); boolean isInMemory = fi.isInMemory(); long sizeInBytes = fi.getSize(); // Write the file if( fileName.lastIndexOf("\\") >= 0 ) { file = new File( filePath + fileName.substring( fileName.lastIndexOf("\\"))) ; } else { file = new File( filePath + fileName.substring(fileName.lastIndexOf("\\")+1)) ; } fi.write( file ) ; out.println("Uploaded Filename: " + filePath + fileName + "<br>"); } } out.println("</body>"); out.println("</html>"); } catch(Exception ex) { System.out.println(ex); } } else { out.println("<html>"); out.println("<head>"); out.println("<title>Servlet upload</title>"); out.println("</head>"); out.println("<body>"); out.println("<p>No file uploaded</p>"); out.println("</body>"); out.println("</html>"); } %> |
Create web.xml file in WEB-INF Folder project
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<?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"> <session-config> <session-timeout> 30 </session-timeout> </session-config> <context-param> <description>Location to store uploaded file</description> <param-name>file-upload</param-name> <param-value> c:\tempp\ </param-value> </context-param> </web-app> |
You must create a folder name “temp” in Read More …
To write a Python program to evaluate the Fibonacci series for n terms.
1 2 3 4 5 6 7 8 9 10 |
x = 0 y = 1 n = int(input("Enter value of n")) for i in range(n): z = x+y print(x) x = y y = z |
Output Enter value of n 10 0 1 1 2 3 5 8 13 21 34
Python Program to Check Leap Year
A leap year is exactly divisible by 4 except for century years (years ending with 00). The century year is a leap year only if it is perfectly divisible by 400. For example,
1 2 3 4 |
2017 is not a leap year 1900 is a not leap year 2012 is a leap year 2000 is a leap year |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# Python program to check if the input year is a leap year or not year = 2000 # To get year (integer input) from the user # year = int(input("Enter a year: ")) if (year % 4) == 0: if (year % 100) == 0: if (year % 400) == 0: print("{0} is a leap year".format(year)) else: print("{0} is not a leap year".format(year)) else: print("{0} is a leap year".format(year)) else: print("{0} is not a leap year".format(year)) |
To Write a Python program to compute the GCD or HCF of two numbers.
Program to find GCD or HCF of two numbers. GCD(Greatest Common Divisor) or HCF (Highest Common Factor) of two numbers is the largest number that divides both of them. Using Loops
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# Python program to find the H.C.F or GCD of two input number # define a function def computeHCF(x, y): # choose the smaller number if x > y: smaller = y else: smaller = x for i in range(1, smaller+1): if((x % i == 0) and (y % i == 0)): hcf = i return hcf num1 = 54 num2 = 45 # take input from the user # num1 = int(input("Enter first number: ")) # num2 = int(input("Enter second number: ")) print("The H.C.F. of", num1,"and", num2,"is", computeHCF(num1, num2)) |
Using Euclidean Algorithm
1 2 3 4 5 6 7 8 9 10 11 |
def computeHCF(x, y): # This function implements the Euclidian algorithm to find H.C.F. of two numbers while(y): x, y = y, x % y return x hcf = computeHCF(54, 45) print(hcf) |
Using Recurssion
1 2 3 4 5 6 7 8 |
def gcd(a,b): if(b==0): return a else: return gcd(b,a%b) a=int(input("Enter first number:")) b=int(input("Enter second number:")) print (gcd(a,b)) |