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

📄 newsedit.java

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

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

/**

 */

public class NewsEdit 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.getNewsEditTemplate ();
		SingleTemplate st;
		st = tempList.searchTemplate ("ROOT");
		if(st==null)
		{
	        htmlOut.setErrorID (htmlOut.SINGLE_TEMPLATE_NOTFIND ,"",
								"无法找到模板","Login");
			htmlOut.outHtml();
			return ;
		
		}
		String sNewsChannelName=new String ();
		sNewsChannelName=request.getParameter ("channel");
		if ((sNewsChannelName==null)||(sNewsChannelName.trim ().length ()<1))
		{
			htmlOut.setErrorID (htmlOut.SINGLE_TEMPLATE_NOTFIND ,"",
								"无法找到新闻频道","Login");
			htmlOut.outHtml();
			return ;
		}
		sNewsChannelName=CommonMethods.DealWithGBCodeOfRequest (sNewsChannelName);
	    DBOperater DB = new DBOperater ("ps_news");
        ResultSet rs = DB.executeQuery ("select * from ps_news where username='"+name+"'and channelname= '"	+sNewsChannelName+"'");
	    if(rs!=null){
        try{
           if( rs.next () )
              ;
		   }
        catch(Exception e){
           }
        }
        DB.close ();

		
		//替换模板文件
		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.addString (sNewsChannelName);
				
		}
		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 + -