⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dateeditdaily.java

📁 JAVA邮件系统
💻 JAVA
字号:
/* 
 *
 */

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

/**

 */

public class DateEditDaily extends HttpServlet {


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

		// 得到名字和口令
		String name,pass;

		Person person = new Person();
		person.setName (CommonMethods.GetUserName(request));
		pass = CommonMethods.GetUserPass (request);
		if( person.getName ()==null || (!person.checkPassword(pass)) )
		{
           	htmlOut.setErrorID (htmlOut.USER_NEED_LOGIN,"",
								"用户不存在或用户密码错误","Login?action=reLog");
			htmlOut.outHtml();
			return;
		}
		name= person.getName ();
	    TemplateList tempList=CommonMethods.getDateEditDiaryTemplate ();
		SingleTemplate st;
		st = tempList.searchTemplate ("ROOT");
		if(st==null)
		{
	        htmlOut.setErrorID (htmlOut.SINGLE_TEMPLATE_NOTFIND ,"",
								"无法找到模板","DateShowDay");
			htmlOut.outHtml();
			return ;
		
		}
		String year= new String ();
		String month= new String();
		String day= new String ();
		year = request.getParameter("y");
		month = request.getParameter ("m");
		day = request.getParameter ("d");
        Calendar myCalendarChange = Calendar.getInstance ();
	    if ((year == null)||(month == null)|| (day == null))
		{	
		   year = myCalendarChange.get(myCalendarChange.YEAR )+"";
		   month = (myCalendarChange.get (myCalendarChange.MONTH )+1)+"";
		   day = myCalendarChange.get(myCalendarChange.DATE )+"";
		}
		int nYear;
		try{
			nYear = Integer.valueOf(year).intValue ();
		}catch(Exception e){
		    nYear = myCalendarChange.get (myCalendarChange.YEAR);
		}
		int nMonth; 
		try{
			nMonth=Integer.valueOf(month).intValue ();
		}catch(Exception e){
	        nMonth=myCalendarChange.get (myCalendarChange.MONTH)+1;
		};
		int nDay;
		try{
			nDay= Integer.valueOf(day).intValue ();
		}catch(Exception e){
			nDay =myCalendarChange.get(myCalendarChange.DATE );
		}
	    if ((nYear <2050 ) && (nYear >= 1900) || (nYear ==1900 && nMonth>1 && nMonth<=12))
				;
		else
		{
			htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE ,"",
								"请选择界于1900年2月到2050年之间的年份","Login");
			htmlOut.outHtml ();
			return;
		}
		String sTitle = "";
		String sContent = "";
	    DBOperater DB = new DBOperater ("ps_daily");
        ResultSet rs = DB.executeQuery ("select  DailyTitle,DailyContent from ps_daily where username='"+name+"'and DailyYear= "
										+nYear+" and DailyMonth="+nMonth+" and DailyDay="+nDay);
	    if(rs!=null){
        try{
           if( rs.next () )
               sTitle = rs.getString (1);
		       sContent = rs.getString (2);
		   }
        catch(Exception e){
           }
        }
        DB.close ();
		if (sContent==null)
			sContent="";
		
		//替换模板文件
		int nKey = st.getKeyNum ();
		String sKey= new String ();
		for(int i=0;i<nKey;i++){
			htmlOut.addString (st.getStringAt (i));
			sKey = st.getKeyAt (i);
			if( sKey.compareTo("cgi-path")==0 )
				htmlOut.addString (CommonMethods.sHostNameCGI);
			if( sKey.compareTo("标题")==0 )
				htmlOut.addStringPlain (sTitle);
			if ( sKey.compareTo("内容")==0)
				htmlOut.addStringPlain (sContent);
			if (sKey.compareTo ("年")==0)
				htmlOut.addString (nYear+"");
			if (sKey.compareTo ("月")==0)
				htmlOut.addString (nMonth+"");
			if (sKey.compareTo ("日")==0)
				htmlOut.addString (nDay+"");
			if (sKey.compareTo ("年历")==0)
				htmlOut.addString ("DateShowYear?y="+nYear);
		}
		htmlOut.addString (st.getEndString());
		//out.println (st.getEndString());
		htmlOut.outHtml();
			
		return;
    }


    public void doPost(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException
    {
		doGet(request,response);
	}
}

⌨️ 快捷键说明

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