newsedit.java
来自「JAVA邮件系统」· Java 代码 · 共 100 行
JAVA
100 行
/*
*
*/
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 + =
减小字号Ctrl + -
显示快捷键?