How to configure Eclipse implementation custom Login interface _java

Source: Internet
Author: User
Tags apache tomcat

Eclipse Tools I believe customization is familiar to developers. But for me this rookie is quite challenging, because I am from learning to work has been studying the operation of the relevant work, no contact with the development of related work, so in the use of more difficult, but for a person with the pursuit of technology, Should be on the road faster, I studied for half a month of Java, because work busy, no time to learn, through this half a month basically understand the most basic concept. Because the company recently updated the architecture, want to some of the company's information to write to SQL, and then through the Web query, so they feel the implementation of the ecclipse under the deployment of the first Web login interface, here for you to share: specific See below:
We also know that running a Web program is most commonly done through Tomcat, IIS, Apache, but the most common personal feeling is tomcat, so you need to download the Windows for Tomcat program, and then you need to configure the JDK on Windows, JRE variables and so on, and 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. Installation Jdk-6u14-windows-i586.exe
5. Configure environment variables: Right-click "My Computer"--> "Advanced"--> "Environment variables"
1 A new Java_home variable in the system variable, the value of the variable is: C:\Program files\java\jdk1.6.0_14 (completed according to their own installation path)
2 new Classpath variable, the variable value is:.; %java_home%\lib;%java_home%\lib\tools.jar
3 Add the variable value in the path variable (existing without new):%java_home%\bin;%java_home%\jre\bin (note that the value of the variable is ";" Separated
6, "Start"--> "Run"--> input "Javac"--> "enter", if the normal print usage instructions to configure success!
The analysis of supplemental environment variables:
Installation path for JAVA_HOME:JDK
Classpath:java load Classpath, only classes can be recognized by Java commands in Classpath, plus a "." Before the path. Represents the current path.
Path: The system can recognize the JAVA,JAVAC command under any path.
7. Eclipse Download: http://eclipse.org/downloads/
Second, we are already in the above environment ready:
The APACHE-TOMCAT program is placed in the D-disk directory.

2. After running the Eclipse program, we created the first project--àdynamic Web project (named Sam)--à and then create the. jsp file, because I found the appropriate template on the Internet, so I need to replace it.
http://down.51cto.com/data/678743
3. We download and open to find our favorite template program and then do the tag. I like this one better, so I'm going to use this template file.

We open the relevant application of the file: because they are HTML files, so we need to open the file to replace the JSP file, and then the CSS to document the copy of the past can be

Third, we first create a new command to: login.jsp file, new default file, we found that there are errors, in fact, this error is also a mistake, because the error is the configuration of the program running environment, for convenience, we must first solve the problem of this error.

2. We click Windows-àpreferences

Server-àruntime Environment--àadd

We are prepared and installed in the environment is apache-tomgcat8.0, so we select this version

We chose the installation path for the Tomcat program

Select after we click Finish

We right-click Dynimac Web Object (Sam)--àbuild path--àconfigure build Path

We choose, Server Runtime

We then choose the Libraries--àadd Library.

We add complete

After the addition was completed, we found that the Apache Tomcat version of the program has been added

We're changing the program's character code to "UTF-8."

The bug problem has been resolved and we are replacing the login login and jump page with the download.

We start by opening the login.html file to open the copied content in text format.

We will delete the new login.jsp file content, except for the first two lines of format language. Paste the contents of the login.html file you just copied

After we paste the results see below:

Next we're going to create a index.jsp file as a jump page. When the login is complete, it jumps to the change page

At the same time we will copy the index.html after the download is opened in text format.

Paste into the index.jsp file.

Because the login interface after downloading is marked information, we need to copy and paste the marked information to the Dymaci Web object for invocation. Copy the following 5 files.

We copy and paste the file

After pasting the result see below:

When the above file configuration is complete, we need to create a server package (Action), right-click Dymanic Web Object (Sam)---Create a new---package
This program is mainly to control the page access and jump.

The name of the Server Packer is generally recommended to use the reverse input of the company domain name: For example, my domain name is iiosoft.com again to enter com.iiosoft.action

Create Complete Server package (Action)

After creating the action, we need to create the Servlte to control the program.

We right click on the server Package-àweb-àservlet

Name we can start at any time again we use Actionservlet

So the program is created and then we need to modify the program.

Once all our programs have been created, we need to create a form within 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 login information to the change form.
For example, the final message is:

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" Utf-8 "%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" > <HTML> <HEAD> <TITLE> Management Center Landing v1.0</ title> <meta http-equiv=content-type content= "text/html; charset=gb2312 "> <link href=" css/admin.css "type=" Text/css "rel=" stylesheet "> </HEAD> <body onload= Document.form1.name.focus ();> <form action= "Actionservlet" method= "POST" > <table height= "100%" Cellspacing=0 cellpadding=0 > "100%" bgcolor= #002779 border=0> <TR> <td align=middle> <table cellspacing=0 cellpadding=0 >468 border=0> <TR> <td> 468></td></tr> <TR> <td>468></TD
></TR></TABLE> <table cellspacing=0 cellpadding=0 >468 bgcolor= #ffffff border=0> <TR> &LT;TD >16>16></TD> <td align=middle> <table cellspacing=0 cellpadding=0 >230 Border=0> <form name=form1 action=? method=post> <tr height=5> <td >5></TD> <td >56></TD> <TD></TD> </TR> <tr height=36> <TD></TD> <TD> user name </TD> <td><input style= " Border-right: #000000 1px solid; Border-top: #000000 1px solid; Border-left: #000000 1px solid;
Border-bottom: #000000 1px solid "maxlength=30 size=24 name=username></td></tr> <tr height=36> <TD>  </TD> <TD> password </TD> <td><input style= "border-right: #000000 1px solid; Border-top: #000000 1px solid; Border-left: #000000 1px solid;
Border-bottom: #000000 1px solid "Type=password Name=password maxlength=30 size=24 name=pass></td></tr> <tr height=5> <td colspan=3></td></tr> <TR> <TD> </TD> <TD> </TD> <td><input type=image height=18 >70 src= "Images/bt_login.gif" ></td></tr ></FORM></TABLE></TD> <td >16>16> </TD></TR></TABLE> <table cellspacing=0 cellpadding=0 >468 border=0> <TR> <TD> 468></TD></TR></TABLE> <table cellspacing=0 cellpadding=0 >468 border=0> <TR> <td align=right><a href= "http://www.865171.cn/" Target=_blank >165 border=0></a></td></tr></table>

 </TD></TR></TABLE> </form> </BODY></HTML>

Code structure before modification:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" > <HTML> <HEAD> <TITLE> Management Center Landing v1.0</ title> <meta http-equiv=content-type content= "text/html; charset=gb2312 "> <link href=" css/admin.css "type=" Text/css "rel=" stylesheet "> </HEAD> <body onload= Document.form1.name.focus ();> <table height= "100%" cellspacing=0 cellpadding=0; 100% "Bgcolor= #002779 border=0& 
Gt <TR> <td align=middle> <table cellspacing=0 cellpadding=0 border=0> <TR> <td></tr> <TR> <td></tr></table> <table cellspacing=0 cellpadding=0 bgcolor= #ffffff border=0> <TR& 
Gt &LT;TD  <td align=middle> <TABLE-cellSpacing=0 cellPa dding=0 border=0> <form name=form1 action=? Method=post> <tr Height=5> <td;</td> <td;</td> <TD></TD></TR> <tr height=36> <td>& Lt;/td> <TD> username </TD> <td><input style= "border-right: #000000 1px solid; Border-top: #000000 1px solid; Border-left: #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> <td><input style= "Border-right: #00000 0 1px solid; Border-top: #000000 1px solid; Border-left: #000000 1px solid; Border-bottom: #000000 1px solid "Type=password maxlength=30 size=24 value=" www.865171.cn "name=pass></td> </TR> <tr height=5> <td colspan=3></td></tr> <TR> <TD> </TD> ; td> </td> <td><input type=image height=18 src= "Images/bt_login.gif" ></TD></TR ></FORM></TABLE></TD> &Lt TD; </tr></table> <TABLE cellSpacing=0 cellpadding=0 border=0> <TR> <td></tr> </TABLE> <table cellspacing=0 cellpadding=0 border=0> <TR> <td align=right><a href= "http:// www.865171.cn/"target=_blank></a></td></" Tr></table></td></tr></table></body> 

Last modified login information name:

Copy Code code as follows:
Name=username password= Password

Finally, we define the user and the name under the ACTIONSERVLT.

String name = Request.getparameter ("username");
String Password = request.getparameter ("password");
SYSTEM.OUT.PRINTLN (name);

After the modification is complete, we can run the test

The page will open normally

After running, we can see the input account and password information through the console.

Next we jump by adding a conditional statement. Let's start by defining the specified account and password for testing.
We define username and password are admin, if the input correctly jumps to the index.jsp page, if the input error jumps to the current page


if (name.equals ("admin") && password.equals ("admin")) {
response.sendredirect ("index.jsp");
} else {
response.sendredirect ("login.jsp");
}

After adding, we carry out the test;

Input right after we log in to jump normal

The above is the entire content of this article, I hope that we can understand, for everyone to help.

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.