Heading

Wednesday, March 5, 2014

Web Application in Java with JDBC, Servlets, JSp and MYSQL DataBase-3

HomePage.html
 Design Home Page as shown below

Important is just the Home Register and Login links
As shown below. Give link to that using anchor tag and use href attribute.
      Home      Login       Register

Web Application in Java with JDBC, Servlets, JSp and MYSQL DataBase-2

web.xml File:


<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <welcome-file-list>
        <welcome-file>Home_Page.html</welcome-file>
    </welcome-file-list>
   
   
        <servlet>
        <servlet-name>Registration</servlet-name>
        <servlet-class>Registration</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Registration</servlet-name>
        <url-pattern>/accept</url-pattern>
    </servlet-mapping>
        <servlet>
        <servlet-name>Authentication</servlet-name>
        <servlet-class>Login</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Authentication</servlet-name>
        <url-pattern>/logme</url-pattern>
    </servlet-mapping>
</web-app>

Web Application in Java with JDBC, Servlets, JSp and MYSQL DataBase-1

Project Architecture of Simple Project (Final Architecture)

Thursday, February 27, 2014

Searching for a string or substring in list of files in a folder

package Examp;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Fileex {
public static void main(String[] args) throws IOException {
   
    String path = "G:\\test\\",a[]=new String[50],s;
    boolean flag=false;
    int j;

    System.out.println("Enter One String to search content in files");
       
    BufferedReader br1=new BufferedReader(new InputStreamReader(System.in));
    s=br1.readLine();

    File folder = new File(path);
    File[] listOfFiles = folder.listFiles();
   
    for(int i=0;i<listOfFiles.length;i++)
    {
        String file=listOfFiles[i].getName();
        BufferedReader br = new BufferedReader(new FileReader("G:\\test\\"+file));
        try {
          
             String line;
             j=0;
             flag=false;
            while ((line = br.readLine()) != null)
            {
                 StringTokenizer st = new StringTokenizer(line);
                while (st.hasMoreTokens())
             {
                    if(s.equalsIgnoreCase(st.nextToken())||line.contains(s))
                    {
                        flag=true;
                    }

                }
                if(flag)
                {
                   a[j]=line;
                  
                }
                 j++;
        }
            if(flag)
            {
                System.out.println(file);
                System.out.println("*********************");
                for(int k=0;k<j;k++)
                {
                    System.out.println(a[k]);
                }
                System.out.println("*********************");
               
               
            }

          }
          catch (Exception e)
        {
                System.out.println("can't open the specified file");
        }
          finally
        {
                br.close();
                   }

    }

    if(!flag)
        {
            System.out.println("no such file available" );
        }
   
  }
}
OutPut:

Enter One String to search content in files
maTHS
maths.txt
*********************
maths is my favourate subject
i studied it when am at SSc
*********************

_________________________________________________
Enter One String to search content in files
sharma
no such file available