How to Load Servlet on StartUp and Call a Method using Java in NetBeansIDE

How to Load Servlet on StartUp and Call a Method using Java in NetBeansIDE



How to Load Servlet on StartUp and Call a Method using Java in NetBeansIDE

1. Open NetBeansIDE.

2. Create a Java Web Project.

3. Create a Servlet (say StartupServlet).

4. Create a Class(say Message) and write method to call say
void display() {
System.out.print("-------Hello--------");
}

5. In StartupServlet override init() method of GenericServlet

and write code calling display() Method in.

6. Change web.xml. Add this line in web.xml

<load-on-startup>0</load-on-startup>

7. Run your project.

8. Finish.

Thank You :)

Comments

Post a Comment

Popular posts from this blog

How to Detect CapsLock key using Java in NetBeansIDE.

How to Perform DES Encryption and Decryption of TXT file in JAVA with NetBeansIDE

How to insert Image in MySQL Database with Java in NetBeansIDE