Jsp-servlet realization of online BBS project small case

Source: Internet
Author: User

Project function: Realize the function of the General BBS Forum Project, publish say that other friends can comment

First, the creation of the database:

The SQL statements are as follows:

    create  table  Span class= "hljs-string" > ' BBS ' .  ' user '  ( int  not< /span> null  auto_increment,  ' username '  char  (20 ) not  null ,  ' UserPassword '   CHAR  (20 ) not  null , primary  key  ());      Create unique index ' PRIMARY '  on ' BBS '. ' user ' (' userid ');
    Create Table ' BBS '.' article '(' ArticleID ' INT  not NULLAuto_increment,' title ' CHAR( -) not NULL,' context ' CHAR( $) not NULL,' Articletime '  Time  not NULL,' userid ' INT  not NULL,Primary Key(' ArticleID ')    );     alter table ' BBS '. ' article ' Add index ' article_user_fk '(' userid '), add constraint ' Artic LE_USER_FK 'foreign key (' userid ') references ' BBS '. 
     
       ' user '(
      ' userid ');                   
          Create unique index ' PRIMARY '  on ' BBS '. ' article ' (' ArticleID ');     Create index ' article_user_fk '  on ' BBS '. ' article ' (' userid ');
    Create Table ' BBS '.' comment '(' Commentid ' INT  not NULLAuto_increment,' Commenttext ' CHAR( $) not NULL,' Commenttime '  Time  not NULL,' userid ' INT  not NULL,' ArticleID ' INT  not NULL,Primary Key(' Commentid ')    );    alter  table  Span class= "hljs-string" > ' BBS ' .           ' comment '  add  index  ' COMMENT_ARTICLE_FK '  ( ' ArticleID ' ), add  constraint
       ' COMMENT_ARTICLE_FK '  foreign  key  ( ' ArticleID ' ) references
        ' BBS ' .  ' article '  ( ' ArticleID ' );     alter  table  Span class= "hljs-string" > ' BBS ' .           ' comment '  add  index  ' COMMENT_USER_FK '  ( ), add   Constraint   ' COMMENT_USER_FK '  foreign  key  () refere NCEs  .  ' user '  ();      Create unique index ' PRIMARY '  on ' BBS '. ' comment ' (' Commentid ');     Create index ' comment_user_fk '  on ' BBS '. ' comment ' (' userid ');     Create index ' comment_article_fk '  on ' BBS '. ' comment ' (' ArticleID ');

Second, the project code is as follows:

The main implementation of the code: solve the problem of Chinese garbled:

 Public  class myfilter implements Filter {    PrivateString encoding=NULL; Public void DoFilter(ServletRequest arg0, Servletresponse arg1, Filterchain arg2)throwsIOException, Servletexception {arg0.setcharacterencoding (encoding);      Arg2.dofilter (arg0, arg1); } Public void Init(Filterconfig arg0)throwsservletexception {encoding = Arg0.getinitparameter ("Encoding");//Get encoding in the configuration file} Public void Destroy() {    }}

configuring in the Web. xml file

<!--filter Chinese garbled problems--    <filter>        <filter-name>Myfilter</filter-name>        <filter-class>Com.xuliugen.util.MyFilter</filter-class>        <init-param>            <param-name>Encoding</param-name>            <param-value>Utf-8</param-value>        </init-param>    </filter>    <filter-mapping>        <filter-name>Myfilter</filter-name>        <url-pattern>/*</url-pattern>    </filter-mapping>

All code here: http://download.csdn.net/detail/u010870518/8570147

Jsp-servlet realization of online BBS project small case

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.