Create a simple online school recruitment interface in jsp model1 mode (4), model1 online school

Source: Internet
Author: User

Create a simple online school recruitment interface in jsp model1 mode (4), model1 online school
Familiar with the model1 model according to the content explained by Han shunping.

The model1 mode is composed of many independent jsp files and java Beans (not mandatory). Then, these jsp files obtain the required data from HttpRequest and perform corresponding business logic processing, then return the result to the browser through Response.

There are two types of model1 development:
1. model1 (pure jsp technology without any java Bean)

2. model1 (jsp + java Bean)

Disadvantages of model1 mode:
1. The presentation layer and business logic layer are mixed together !!!
2. in the development process, it is not conducive to collaborative development by many people.
3. It is not conducive to later maintenance.
Advantages of the model1 mode:
1. simple and fast development;
2. Suitable for small projects.

We use the pure jsp Technology in model1 mode to develop a simple user login System (without database temporarily ).
Mainly for learning:
1. Familiar with jsp page Jump (the following two items will be studied later)
2. How does jsp operate databases;

3. How to display data in jsp/How To pagination


It mainly involves three pages:

Login. jsp

Verify. jsp

Welcome. jsp


Business logic:

Login. jsp is the login page. You need to enter the user name and password to go to verify. jsp for verification:

If the user name is dahuang and the password is 123, the welcome. jsp page is successfully displayed. Otherwise, login. jsp is returned.


The login. jsp page code is as follows:

<% @ Page language = "java" contentType = "text/html; charset = gbk" pageEncoding = "gbk" %> <! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd"> 

The verify. jsp code is as follows:

<% @ Page language = "java" contentType = "text/html; charset = gbk" pageEncoding = "UTF-8" %> <! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd"> 

The welcome. jsp code is as follows:

<% @ Page language = "java" contentType = "text/html; charset = gbk" pageEncoding = "UTF-8" %> <! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd"> 

Display Effect:

The logon interface is as follows:


The logon success page is as follows:



What is the relationship between Model1 and Model2 In the MVC design model?

Model 1
Model 1 is Based on JSP files, which are composed of some mutually independent JSP files and some other Java classes (not required ). The JSP obtains the required data from the HTTP Request, processes the business logic, and then returns the result to the browser through Response.

Model 2
Using object-oriented technology to implement the MVC mode, thus extending the JSP/Servlet mode is becoming the Model 2 mode. In the Apache Jakarta project, Struts is a good framework for implementing Model 2. It processes the presentation layer through some M Tag Lib and uses ActionFrom Bean to represent data, use an ActionServlet provided by you as the Controller to control page flow.

To put it bluntly, model1 is a pure jsp + java with no framework involved. Value domains are transmitted through response and request objects, while model2 uses the popular struts framework.

Is MVC used to create a small project using jsp? The model1 model should be enough. I feel that model2 is used for large-scale projects.

If it is a project that is just finished, it doesn't matter.

MVC is also used for small projects. There are at least two advantages:
1. When small projects grow and become medium-sized or even large projects, it will be better to use MVC.
2. Using MVC in small projects will make you more familiar with and understand MVC so that you can deal with large projects in the future.

It is better to have strict requirements on yourself during study.

(PS: To be honest, I am also very disgusted with the use of MVC in many dogmas ...... But I have to say that it is quite pleasant to read the code by clearly layering and modeling the application)

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.