Posts

Login using Ajax, J2ee, Oracle 10g

Image
Get Finest Laptops from AMAZON Login.jsp <%--     Document   : index     Created on : 2 Dec, 2013, 6:43:57 PM     Author     : snlkjha --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html>     <head>         <link rel="stylesheet" href="Know_your_employee.css.css">         <script type="text/javascript" src="know_your_employee.js"></script>         <style type = "text/css">             td{font-weight:bold;}             select{font-weight:bold;color:blueviolet;}         </style>     </head>     <body>         <div id="nav">             <div id="flip"><span id="t">Know Y...

Cascading DropDownList Using Ajax, J2ee, Oracle

Image
Step -I Index.jsp <%--     Document   : Cascading Drop Down List     Created on : 26 Jul, 2013, 7:26:39 PM     Author     : snlkjha     Description:     Front end: JSP using JSTL     Middle tier: Java Classes     Database    : Oracle 10G     sample table used test123(country,state,dist) one-many-many     MVC has been Follwed. --%> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html>     <head>         <link rel="stylesheet" href="Styles/ddl_css.css">         <script language="javascript" src="Script/ajax.js"></script>         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">         <title>J...

We need to write the function to check the password entered is correct or based on the following conditions..

a) It must have atleast one lower case character and one digit. b)It must not have any Upper case characters c) length should be b/w 5-12. d) It should not have any same immediate patterns like abcanan1 : not acceptable coz of an an pattern abc11se: not acceptable, coz of pattern 11 123sd123 : acceptable, as not immediate pattern adfasdsdf : not acceptable, as no digits Aasdfasd12: not acceptable, as have uppercase character Solution : package assignment1; import java.util.Scanner; /**  * @author Snlkjha  */ public class ValidPassword {   /*It must have atleast one lower case character*/   public static boolean islower(String password){     char pass[]=password.toCharArray();     for(int i=0;i<pass.length;i++)         if((int)pass[i]>=97 &&(int)pass[i]<=122) return true;       return false; } /*It must not have any Upper case characters*/ public static boolean isup...

A string of characters is given.Find the highest occurrence of a character and display that character.

eg.: INPUT: AEGBCNAVNEETGUPTAEDAGPE OUTPUT: E or I,J(if equal occurance) package assignment1; /*  * @author snlkjha  */ public class Charfreq {         public static void charFreq(String x){                 String toUpperCase = x.toUpperCase();   /*If the given string is in lower case or mixed case , convert it into upper case.*/         char y[]=toUpperCase.toCharArray();         int freq[]=new int[26],max=0;         for(int i=0;i<y.length;i++) ++freq[(int)y[i]-65];         System.out.println("________________________________________");         for(int i=0;i<y.length;i++)             if(freq[i]!=0)  System.out.println((char)(i+65)+" "+freq[i]);         for(int i=1;i<freq.length;i++)  max=freq[max]<freq[i]?i:max;   ...

Code to upload multiple files simultaneously using JSP, Servlet .

Image
Step 1 : Create a jsp page. index.jsp <%--      Document   : index     Created on : 21 Sep, 2013, 5:58:32 PM     Author     : snlkjha --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html>     <head>         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">         <title>JSP Page</title>     </head>     <body>         <form action="UploadServlet" method="post" enctype="multipart/form-data">             <input type="file" id="file" name="file1" accept="image/*"  multiple="muliple" required/><br>             <input type="submit"/>            <br><br> ${requestScope.message} ...

Code to create Zip file using Java .

/*  * To change this template, choose Tools | Templates  * and open the template in the editor.  */ package Java_Classes; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; /**  *  * @author snlkjha  */ public class Zip {     public static void zipFolder(String srcFolder) throws Exception {         FileOutputStream fileWriter = new FileOutputStream(srcFolder + ".zip");         ZipOutputStream zip = new ZipOutputStream(fileWriter);         addFolderToZip("", srcFolder, zip);         zip.flush();         zip.close();     }     private static void addFolderToZip(String path, String srcFolder, ZipOutputStream zip) throws Exception {         File folder = new File(srcFolder);   ...

Write a program to get the subsequence of a bit 1 and 0 given in a array of bits.

/*  *Write a program to get the subsequence of a bit 1 and 0 given in a array of bits.(Equal No. of 1's and 0's)   For example :  array={1,0,1,1,0,1,1}   Output={1,0,1,0}                 array={1,1,0,1,0,0,1,1} Output={1,1,0,1,0,0}  */ package assignment1; import java.util.ArrayList; /**  * @author snlkjha  */ public class SubSequences {          public static ArrayList<Integer> subsequence(int a[]){    // Array a contains values in the form of 1's and 0's                 ArrayList<Integer> sub=new ArrayList<>();         int count1=0,count0=0,min;         for(int i=0;i<a.length;i++){             if(a[i]==1) count1++;   // counting No of 1's             else count0++;         ...