Home Tutorial Servlet Java Servlet Change Background Color

 
 

Share on Google+Share on Google+
Java Servlet Change Background Color
Posted on: July 24, 2010 at 12:00 AM
Advertisement
In this section, you will learn how to to change the background color of the servlet automatically.

Java Servlet Change Background Color

You can provide an effective way to the web page by changing the background color of the web page. In servlet, you can do this by using javascript. Here, we are going to change the background color of the servlet automatically after every 10 seconds. We have define nine colors in the javascript which should be displayed randomly.

Here is the code:

import java.io.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ChangeBackgroundColor extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {
		PrintWriter out = response.getWriter();
		out.println("");
		out.println("");
		out.println("

Hello World

"); } }

Output:

After 10 seconds, color will get changed:

Advertisement

Related Tags for Java Servlet Change Background Color:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 24, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com