Real-field JSP advanced programming One

Source: Internet
Author: User

Many JSP beginners in learning simple JSP programming, often stay in the JSP inside the SQL statement to tune a JavaBean database connection stage, stalled.

This simple tutorial is expected to help beginners learn to use OOP ideas for JSP programming.

Scenario: A simple news system that consists of 2-3 data tables.

The database system uses MySQL, and of course it is similar to others.

First datasheet, and the main data sheet: News

create table news2 (newsid int not null,
userid int,
kwid int, // 关键词外键
title varchar(100),
content text,
hits int,
cdate varchar2(30),
mdate varchar2(30),
primary key(newsid));

Insert one more sample data:

insert into news2 (newsid, title, content) values (1, 'test title', 'test body');

Design idea: Programming with MVC pattern, packing data in a helper class News.java,

And through the Newsdao.java database operation.

In the design phase, UML is used to sketch the object of the system.

... omitted here

The main methods of Newsdao are:

1. Public News getnewsbyprimarykey (int newsid);

2. Public news[] Getrecentnews ();

3. Public news[] Gethotnews ();

......

Related Article

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.