makelogin.java

来自「JAVA邮件系统」· Java 代码 · 共 74 行

JAVA
74
字号
/* 
 *
 */

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

/**
 * 
 *
 * @author Chen Xin Wu
 */

public class MakeLogin extends HttpServlet {


    public void doPost(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException
    {
		doGet(request,response);
	}
	public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException
    {
		try{
			HtmlOut htmlOut = new HtmlOut (response);
				

			String sFile = CommonMethods.sHtmlPath+"/loginfirst.html" ;
			File file = new File(sFile);
			if( file.exists() ){
				//current time;
				Calendar date=Calendar.getInstance ();
				
				//file time
				long time = file.lastModified();
				java.util.Date  fileTime = new java.util.Date(time);
				Calendar date1=Calendar.getInstance ();
				date1.setTime(fileTime); 
				
				if( date1.get(date.DAY_OF_MONTH )==date.get(date.DAY_OF_MONTH ) )
					response.sendRedirect ("/loginfirst.html");
				return;
			}

			TemplateList tempList = CommonMethods.getMakeLoginTemplate ();
			ReplaceEngineLogin re = new ReplaceEngineLogin();
			Person p=new Person();
			p.setName ("test");
			if(tempList!=null){
				if( !re.replace(tempList,p,htmlOut) ){
					htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE  ,
										"","页面生成失败!","");
				}
			}
			else{
				htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE  ,"","模板文件错误!","");
			}
			htmlOut.writeHtml( sFile );
			htmlOut.outHtml();
		}catch(Exception e){
		}
    }
}



⌨️ 快捷键说明

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