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++;         ...

Describe how a single array can be used to implement two stacks.

#include<stdio.h> #include<stdlib.h> #define size 10 /* Macro definition */ int top1 = -1, top2 = size; /* Global variable declaration */ int a[size]; int main() {     int ch, n1, n2;     while (1) {         printf("\n=====================\n");         printf("-- Menu Selection --|\n");         printf("=====================\n");         printf("1. Push |\n");         printf("2. Pop |\n");         printf("3. Display |\n");         printf("0. Exit |\n");         printf("=====================\n");         printf("Enter choice(0-3):");         scanf("%d", &ch);         switch (ch) {             case 1:                 printf("Enter n1:");   ...

Array Implementation of queue using C

#include<stdio.h> #include<stdlib.h> #define size 5 #define TRUE 1 #define FALSE 0 typedef struct {     int a[size];     int front;     int rear; } queue; queue *q; int main() /* main() function begins program execution */ {     int ch; /* variable declarion for choice in switch case */     int num; /* variable declaration for data */     q = (queue*) malloc(sizeof (queue)); /*Memory Alloaction*/     q->front = -1;     q->rear = -1;     while (1) {         printf("\nARRAY IMPLEMENTATION OF CQUEUE.\n");         printf("\n======================\n");         printf("|-- Menu Selection --|\n");         printf("======================\n");         printf("| 1. Enqueue |\n");         printf("| 2. Dequeue |\n");         prin...

Linked List Implementation of a stack

#include<stdio.h> #include<stdlib.h> #define TRUE 1 #define FALSE 0 #define defCELL(ETYPE,CELL,STACK) typedef struct slist{ ETYPE data;struct slist *next;}CELL; defCELL(int, CELL, slist) CELL *top = NULL, *temp;    //Global declaration int push(int n);                      /*prototype declaration*/ int pop(); int display(); int clear(); int isempty(); int main() {     int ch, n; //Local variable declaration     while (1) {         printf("\n***Menu Selection***\n");         printf("1: PUSH\n");         printf("2: POP\n");         printf("3: CLEAR\n");         printf("4: ISEMPTY\n");         printf("0: EXIT\n");         printf("********************\n");         printf("Enter your choice(0-4):");    ...

Array Implementation of stack using C

#include<stdio.h> #include<stdlib.h> #define size 5 #define TRUE 1 #define FALSE 0 typedef struct //STRUCTURE DEFINITION {     int data[size];     int top; } stack; stack *stk; //GLOBAL VARIABLE DECLARATION int push(int); //prototype declarations int pop(); int display(); int isfull(); int clear(); int isempty(); int main() {     int n, i, ch;     stk = (stack*) malloc(sizeof (stack)); //DYNAMIC MEMORY ALLOCATION     stk->top = -1;     while (1) {         printf("\n***Menu Selection***\n");         printf("1: Push\n");         printf("2: Pop\n");         printf("3: Clear\n");         printf("4: IsEmpty\n");         printf("5: IsFull\n");         printf("0: exit.\n");         printf("********************\n");     ...

Addition, Substraction & Multiplication of two polynomials using C++

#include<iostream> #include<stdlib.h> #define RESET_COLOR "\e[m" #define GREEN  "\e[32m" using namespace std; class polynomial { public:     int *coeff, degree; /* variable declaration */     int get_data(); /*function declaration */     int display(int *coeff, int degree);     void addition(polynomial P1, polynomial P2);     void substraction(polynomial P1, polynomial P2);     void multiplication(polynomial P1, polynomial P2); }; int polynomial::display(int *coeff, int degree) {     int i, j;     for (i = degree; i >= 0; i--) {         cout << coeff[i] << "x^" << i;         if ((i - 1) != -1)             cout << "+";     }     cout << "\n";     return 0; } int polynomial::get_data() {     int i;     cout ...