ActionTopicSearch.java
上传用户:jishiqi_cj
上传日期:2022-08-08
资源大小:24765k
文件大小:1k
源码类别:

Java编程

开发平台:

Java

  1. package StudyBbs;
  2. import javax.servlet.http.HttpServletRequest;
  3. import javax.servlet.http.HttpServletResponse;
  4. import org.apache.struts.action.Action;
  5. import org.apache.struts.action.ActionForm;
  6. import org.apache.struts.action.ActionForward;
  7. import org.apache.struts.action.ActionMapping;
  8. import javax.servlet.ServletContext;
  9. import javax.sql.DataSource;
  10. import java.sql.Connection;
  11. import java.sql.Statement;
  12. import java.sql.ResultSet;
  13. import java.sql.SQLException;
  14. import java.util.*;
  15. import javax.servlet.http.*;
  16. import org.apache.struts.action.DynaActionForm;
  17. public final class ActionTopicSearch extends Action{  
  18. public ActionForward execute(
  19. ActionMapping mapping,
  20. ActionForm form,
  21. HttpServletRequest request,  
  22. HttpServletResponse response) throws Exception {
  23.     DynaActionForm topicAdminform = (DynaActionForm) form;         
  24. String title = (String)topicAdminform.get("title");
  25.         HttpSession session = request.getSession();
  26. Vector topics = new Vector();
  27.     ServletContext context = servlet.getServletContext();
  28. DataSource dataSource = 
  29. (DataSource)context.getAttribute(Constants.DATASOURCE_KEY);
  30.         DB db = new DB(dataSource);
  31.         
  32. topics = Topic.Search(db,title);
  33. session.setAttribute(Constants.TOPIC_LIST_KEY,topics);
  34. session.setAttribute("searchtopic",title);
  35.    
  36. db.close();
  37.     return (mapping.findForward("toTopicAdmin"));//主题页面
  38.   }
  39. }