I believe that customization is very familiar to the development of developers, but it is quite challenging for my rookie, because I have been studying and maintenance work from studying to work. Work, so it is difficult to use, but for a person who is pursuing technology, it should be faster. I learned Java for half a month. Because of the busy work, I have no time to learn. Know the most basic concept. Because the company has recently updated the architecture, I want to write some information from the company to SQL, and then query through the web, so I explore the deployment of the first web login interface under ECCLIPSE.
We also know that running the web program is most commonly implemented through Tomcat, IIS, Apache, but the most common individuals still think that Tomcat, so you need to download the Windows for Tomcat program, and then you need to configure JDK, JRE variables and other issues on Windows. ; Finally, prepare the Eclipse program;
1. Windows for tomcat program download: http://tomcat.apache.org/
2. JDK download: http://rj.baidu.com/soft/detail/14459.html? ALD
3. JDK, JRE environment variable configuration:
4. Install JDK-6U14-Windows-I586.exe
5. Configure environment variables: Right-click "My Computer"-> "Advanced"-> "Environment variable"
1) Create a new java_home variable in the system variable. The variable value is: C:/Program Files/Java/JDK1.6.0_14 (fill in according to your own installation path)
2) Create a new classpath variable, the variable value is:;%java_home%/lib;%java_home%/lib/tools.jar
3) Add variable values in PATH variables (existing no need to be built):%java_home%/bin;%java_home%/jre/bin (pay attention to ";" separate)
6. "Start"-> "Run"-> Enter "Javac"-> Enter. If it can be used normally, the configuration is successful!
Analysis of supplementary environment variables:
Java_home: JDK installation path
ClassPath: Java loading paths can only be identified in the Java command in classpath. Add a "." to indicate the current path in front of the path.
PATH: The system can recognize Java and Javac commands under any path.
7. Eclipse download: http://eclipse.org/downloads/
2. We are already ready for the above environment:
The Apache-Tomcat program is placed in the D drive and the directory
2. After running the ECLIPSE program, we create the first project -àdynamic web project (name SAM)-à and then create a.jsp file. Because I found the corresponding template online, I need to replace it.
http://down.51cto.com/data/678743
3. After downloading, open and find the template program that we like and then mark it. I prefer this, so I prepare for this template file
We open the relevant application of the file: Because they are all HTML files, we need to open the file to the JSP file, and then copy the CSS mark file
3. First of all, we create a new command: Login.jsp file. After the new default file is created, we find that there are errors. In fact, this error is also a mistake. This error problem.
2. We click Windows-àpreferences
Server-àruntime environment --àadd
Our environmental preparation and installation are Apache-Tomgcat8.0, so we choose this version
We choose the installation path of the Tomcat program
After choosing, we click to complete
Let's right-click Dynimac Web Object (SAM)-àbuild Path-àconfigure Build Path
We chose, server runtime
We then choose libraries-àadd library
We add to complete
After the addition, we found that the program of the Apache Tomcat version has been added
We are changing the character code of the program to "UTF-8"
The program error problem has been solved. Next, we replace the downloaded login login and jump page.
We first open the login.html file to open the copy content in the text format.
We delete the content of the new login.jsp file, except for the first two lines of format language. Paste the content of the login.html file just copied
See the result of our paste:
Next, we will create an index.jsp file as a jump page. After the login is completed, it will jump to the page to change the page
At the same time, we will copy the downloaded index.html in the format of the text.
Paste in the index.jsp file.
Because the downloaded login interface is marked information, we need to copy and paste the labeling information to the Dymaci Web Object for calling. Copy the following 5 files.
We copy files after copying
See the results after paste: see:
After the above file configuration is completed, we need to create a Server Package (action); right-click the Dymanic Web Object (SAM) --- New --- Package
The program is mainly controlled by the access and jump of the page.
Server Packer's name is generally recommended to use the company's domain name reverse input: for example, my domain name is iiosoft.com again to enter com.iiosoft.ACTION again
Create a Server Package (ACTION)
After creating ACTION, we need to create a service to control the program.
We right-click Server Package-àWeb-àServlet
We can start arbitrarily, and once again we use ActionServlet
So the program is created, and we need to modify the program.
After all our programs are created, we need to create form in the login.jsp file,
Copy code code as follows: <form action = "actionServlet" method = "post">
The main thing is to add <FORM> <Form/> information to add the login information to the change.
For example, the final information is:
<%@page Language = "Java" ContentType = "Text/HTML; Charset = UTF-8" PageEncoding = "UTF-8"%> <! Doctype html public "-// W3C // DTD HTML 4.0 Tran sitional // en "> <HTML> <Head> <Title> Management Center Log in V1.0 </Title> <META HTTP-EQUIV = Content-Type Content =" Text/HTML; Charset = gb2312 "> <link href =" css/adimin .css "Type =" Text/CSS "R =" STYLESHEET "> </Head> <Body onload = DOCUMENT.FORM1.Name.focus ();> <Form Action =" ActionServlet "Method =" Post "> < Table Cellspacing = 0 Cellpadding = 0> "100%" BGCOLOR =#002779Border = 0> <TD Align = MIDDLE> <Table Cellspacing = 0 Cellpadding = 0> 468 Img height = 23 SRC = "Images/Login_1.jpg"> 468> </TD> </TR> <TD> <IMG Height = 147 SRC = "Images/Login_2.jpg"> 468> </td> /TR> </Table> <Table Cellspacing = 0 Cellpadding = 0> 468 BGCOLOR =#FFFFFFF BORDER = 0> <TD> 16> <IMG Height = 122 SRC = "Images/Login_3.jpg"> 16> </Td> <td Align = Middle> <Table Cellspacing = 0 Cellpadding = 0> 230 Border = 0> <FORM NAME = FORM1 Action =? Method = Post> <TR HEIGHT = 5> </TD > <Td> 56> </td> <td> </td> </tr> <tr height = 36> <td> </td> <td> Username </td> <td> <inputStyle = "" Border-Right: #000000 1px solid; border-top: #000000 1px solid; Border-heft: #000000 1px solid; border-BOTTOM: #000000 1px solid "maxlength = 30 size = 24 n ame = username> </td> </Tr> <try = 36> <td> </td> <td> password </td> <nputstyle = "border-right: #000000 1px solid; border-top: #000000 1px solid; Border-heft: #000000 1px solid; border-bottom: #000000 1px solid "type = password name = password maxlength = 30 size = 24Name> </td> </tr> ght = 5> <TD COLSPAN = 3> </td> </tr> <l> <td> </td> </td> </td> <td> <input type = image height = 18> 70src = "images/bt_login.gifif"> Not </Table> <Table Cellspacing = 0 Cellpadding = 0> 468 Border = 0> <TD> <IMG Height = 16 SRC = "Images/Login_5.jpg"> 468> </TD> </Tr> < /TABLE><TABLE cellSpacing=0 cellPadding=0 >468 border=0><TR><TD align=right><A href="http://www.865171.cn/" target=_blank><IMGheight=26 SRC = "Images/Login_6.gif"> 165Border = 0> </a> </td> </TABLE> </TD> </TABLE> </Form> </body> </Html>
Code structure before modifying:
<! Doctype html public "-// W3C // dtd HTML 4.0 transitional // en"> <html> <head> <Title> Land = "Text/HTML; Charset = gb2312"> <link href = "css/admin.css" type = "text/css" rel = "styleSheet"> </head> <body = document.form1.name. Focus ();> <Table Cellspacing = 0 Cellpadding = 0; 100%"BGCOLOR =#002779 Border = 0> <TD Align = MIDDLE> <Table Cellspacing = 0 Cellpadding = 0 Border = 0> <TR > <TD > <IMG Height = 23 SRC = "Images/Login_1.jpg"; </td> </tr> <td> <IMG Height = 147 SRC = "Images/Login_2.jpg"; </td> < /TR> </Table> <Table Cellspacing = 0 Cellpadding = 0 BGColor =#FFFFFFF BORDER = 0> <TR> <TD; <IMG Height = 122 SRC = "Images/Login_3.jpg"; Align = MIDDLE> <Table Cellspacing = 0 Cellpadding = 0 Border = 0> <FORM NAME = FORM1 ACTION =? Method = Post> <TR Height = 5> </td> </td> <TD> <TD> <TD> <TD > </Td> </tr> <tr heart = 36> <td> </td> <td> Username </td> <nput style = "border-right: #000000 1px solid; border- Top: #000000 1px solid; border-heft: #000000 1px solid; border-bottom: #000000 1px solid "maxlength = 30 size = 24 value =" www.865171.cn "name = name> </Td> </ TR> <TR Height = 36> <TD> </TD> <TD> Password </td> <nput style = "border-right: #000000 1px solid; border-top: #000000 1px solid; -Left: #000000 1px solid; border-bottom: #000000 1px solid "type = password maxlength = 30 size = 24 value =" www.865171.cn "name> </td> </tr> TR Height = 5> <TD COLSPAN = 3> </TD> </TR> <TD> </TD> </Td> </Td> <TD> <input Type = Image Height = 18 SRC = "Images/ BT_LOGIN.GIF "> </TD> </TR> </Form> </Table> </TD> <TD; <IMG Height = 122 SRC =" Images/Login_4.jpg "; </td> </tr > </Table> <Table Cellspacing = 0 Cellpadding = 0 Border = 0> <TD> <IMG Height = 16 SRC = "Images/Login_5.jpg"; </TD> </Table> <Table Cellspacing = 0 Cellpadding = 0 Border = 0> <TD Align = Right> <A href = "http://www.865171.cn/" target = _blaank> <IMG Height = 26 SRC = "Imag ES /login_6.gif "border = 0> </a> </td> </tr> </table> </td> </tr> </body> </html>
Finally modify the login information name:
Copy code code as follows: name = username password = password
Finally, we define users and names under ActionServlt
String name = request.getparameter ("username"); string password = request.getparameter ("password"); System.out.println (name); ln (password); After the modification is completed, we can run for testing
Page can open normally
After running, we can see the input account and password information through the console
Next we jump through the conditional statement. We first define the specified account and password for testing.
We define the username and password as admin.
If (name.equals ("adimin") &&q password.equals ("admin") {response.sendredirect ("index.jsp");} else {response.sendredirect ("login.jsp");} } After adding, we will test;
After the input is correct, we log in and jump to normal
The above is all the contents of this article. I hope everyone can understand and help everyone.