counter.java

来自「java源码文件。可供初学者选用。大家可以看看。」· Java 代码 · 共 42 行

JAVA
42
字号
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;



public class Counter extends HttpServlet
{     

static int counter;    

public void init(ServletConfig config) throws ServletException      
{     
	super.init(config);     
}

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException     

{            

	response.setContentType("text/html");            

	PrintWriter out=response.getWriter();            

	counter++;            
	out.println("<html>");            
	out.println("<head><title>Money Banks, Inc. -- Welcome Page</title></head>");            
	out.println("<body bgproperties=\"fixed\" bgcolor=\"#CCCCFF\">"); 
 	out.println("<p><b><font><font size=\"6\">Welcome to Money Banks, Inc.</font></font></b></p>");
	out.println("Money Banks, Inc. welcomes you to the site. Money Banks, Inc. is a leading bank dealing and fulfilling the needs of all categories: financial organizations, hospitals, universities, and individuals. The services offered by Money Banks include bank accounts and loans for all needs. You will find complete information regarding various schemes of the bank in this site. In addition, the site enables online banking transactions. You can view your account details and if not an account holder, you can apply for an account online. You'll also find various utilities such as interest calculator and foreign exchange calculator on this site.");
out.println("<p><b><fontsize=\"3\"><a href=\"Home_page.htm\">Click here to continue.</a></font></b></p>");
           
	out.println("You are viewer number   " + String.valueOf(counter)+ "  visting our Web site."+ "\n");            
	out.println("</body></html>");     
}  

public String getServletInfo()     
{            
	return "BasicServlet Information";     
}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?