1. First create an HTML page collection input, the fool will, pass the parameters to Color
2. Then the servlet collects the parameters and establishes an instance with the parameter through JavaBean.
Bean Object = New bean;
3. Then follow the GET method of JavaBean to return to the Color, servlet to determine .// Equals () Method.
Object.getcolor ();
4. Servlet is judged to the corresponding JSP page
String addr = ...
Core method:
Reqest.setttribute ("Instance", Object);
RequestDispatcher Dispatcher = Request.GetRequestDispatcher (AddR);
Dispatcher .forward (Request, Response);
5.jsp page reads the corresponding String based on the example established by the previous example.
This program begins with the book, and later written itself.
The following code is not very understanding, and the establishment of several objects? That is an example? Especially SetAttribute ("RED", color);
Is it in front of the replacement?
String TempColor = Request.GetParameter ("color");
ColorBean Color = New ColorBean (TempColor);
Request.setttribute ("Red", Color; RequestDispatcher Dispatcher = Request.GetRequestDispatcher (addr);
Dispatcher.Forward (Request, Response);
You can now implement the MVC architecture, however, where the object's generation process is still not understood, the object, the object ...
The following is the source code:
among them
INPUT.JSP is the collection color page
Wantcolor.java is servlet
ColorBean.java is Javabean
Others are three JSP pages to connect JavaBean display colors
The book is classic, why are I not Americans?
***********
//input.jsp
<% @ Page ContentType = "text / html; charset = GB2312"%>
hEAD>