Home Tutorial Servlet Java Servlet Change Background Color

 
 

Java Servlet Change Background Color
Posted on: July 24, 2010 at 12:00 AM
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:

Related Tags for Java Servlet Change Background Color:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.