Hi All,

Am trying to create a small web page in JSP in which it will get it css file name from a configuration file and load it , if the values in the confiugration file has been changed then this jsp page should be refreshed automically

I have write and collect some code from the net but am getting some error

the following are the files

1. index.jsp

Java Code:
<jsp:useBean id="man" class="test.CheckingFileChange"/>
  <html>
   <head>
   <LINK href="<jsp:getProperty name='man' property='cssFileName'/>" rel="stylesheet" type="text/css">
  <title>JSP Page</title>
  </head>
   <body>
   <form>
   <h2><root>Hello World!</root></h2>
   </form>
    </body>
  </html>


2.servlet called "CheckingFileChange.java"

package test;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sun.mail.iap.Response;

/**
 * Servlet implementation class CheckingFileChange
 */
public class CheckingFileChange extends HttpServlet implements FileChangeListener {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
	public CheckingFileChange(boolean b) {
    	System.out.println("Example Construcator");
        this.useClasspath = b;
	reloadProperties();
    }
	
    public CheckingFileChange() {
        //super();
        // TODO Auto-generated constructor stub
    	reloadProperties();
    	System.out.println("here we are inside checking the super");
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		//super.doGet(request, response);
		System.out.println("hi am here get");
		
		response.sendRedirect("index.jsp");
		System.out.println("Going to checkFileChangeOrNot() ");
		checkFileChangeOrNot();
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		System.out.println("hi am here post");
		//super.doPost(request, response);
		
	}
	
	public void checkFileChangeOrNot(){
		
		boolean useClasspath = false;

		try {
			System.out.println("the value of the arg is ");
			String[] anArray;  
			anArray = new String[10];
			anArray[0] = "Example.java";
			
			useClasspath = Boolean.valueOf(anArray[0]).booleanValue();
		    //useClasspath = Boolean.valueOf(args[0]).booleanValue();
		}
		catch (Exception e) {
			System.out.println("There is some exception and going to exit");
		    System.out.println("Usage: java Example <true|false>");
		    e.printStackTrace();
		    System.exit(1);
		}

	       // Example ex = new Example(useClasspath);
	        System.out.println("no am going to terminate the program ");
	        while(true){
	        	try {
					Thread.sleep(60000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
	        }
	        }

	private static final String PROPERTIES_FILE = "f:/config.properties";

    private boolean useClasspath;
    private long checkPeriod;
    private String cssFileName;
   

    

    public long getCheckPeriod() {
    	System.out.println("getCheckPeriod");
        return checkPeriod;
    }

    public synchronized void setCheckPeriod(long period) {
        log("Setting checkPeriod: " + period);
        checkPeriod = period;
	try {
	    FileMonitor.getInstance().addFileChangeListener(this, 
							PROPERTIES_FILE, 
							checkPeriod);
	}
	catch (FileNotFoundException e) {
	    e.printStackTrace();
	}
    }

    public String getcssFileName() {
        return cssFileName;
    }

    private synchronized void setcssFileName(String email) {
        log("Setting emailAddress: " + email);
        cssFileName = email;
    }

  
    
  

    private void reloadProperties() {
    	System.out.println("reloadProperties()");
	Properties props = new Properties();
        InputStream in;

	try {
            if (useClasspath) {
	        in = getClass().getClassLoader().getResourceAsStream(PROPERTIES_FILE);
	    }
	    else {
	        in = new FileInputStream(PROPERTIES_FILE);
	    }

	    props.load(in);
	    in.close();
	}
	catch (IOException e) {
	    e.printStackTrace();
	}

	setCheckPeriod(Long.parseLong(props.getProperty("checkPeriod")));
	setcssFileName(props.getProperty("cssFileName"));
	//setLogLevel(Integer.parseInt(props.getProperty("logLevel")));
    }

    public void fileChanged(String fileName) {
    	System.out.println("fileChanged(String fileName)");
        reloadProperties();
        System.out.println("We are going to redirect to main index.jsp");
        HttpServletResponse response = null ;
        try {
			response.sendRedirect("index.jsp");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        
    }

    public void log(String s) {
        System.out.println(s);
    }

	}





3. FileChangeListener.java

package test;

public interface FileChangeListener {
    /** Invoked when a file changes.   
     * @param fileName name of changed file.
     */
    public void fileChanged(String fileName);
}



the following files are placed in the drive f:

4.configuration file config.properties

# Sample properties
checkPeriod=30
cssFileName=f:/style1.css


5. style sheet style1.css



  root {
 
  display: block;
 
  font-size: 4px;
 
  font-style: italic;
 
  font-weight: normal;
 
  font-variant: normal;
 
  color: green;
 
  background-color: #ffffcc;
 
  background-attachment: none;
 
  font-family: Georgia,'Times New Roman',times,serif;
 
  }

6.style2.css same as style1.css with color  as red
please help me in that