Summary of server integration configuration experience in Apache + Tomcat + MySQL + JSP + PHP under Windows

xiaoxiao2021-03-06  14

1. Author: moonsbird

Topic: Windows Apache Tomcat MySQL JSP PHP server integrated configuration experience summary

Time: 2004.8.19

First published in Jincheng Station, Southwest Jiaotong University

2. This article is a summary of the author to learn the JSP / Configuration Server environment for several years. It can be reproduced, but please indicate it.

I started learning JSP for a long time, there are many examples of JSP integration, but there are many problems.

For the integration of Apache Tomcat MySQL JSP PHP, some differences in different Tomcat and Apache versions.

Even if you e-text is very good, go see Tomcat and Apache's manual, and it is not necessarily integrated successfully. Summer vacation at home, online speed is not like

So in Jiaotong University --- Lao Hua Drawn Broken Car Slow, so based on this author to see a large number of online information, ly, write this article

Zhang hopes to provide convenience for beginners, and can also serve as a guest's reference manual.

JSP is excellent, it is based on Java technology, using JavaBean / Servlet production dynamic website, Java powerful facing

Like programming makes JSPs that have a unique advantage relative to PHP and ASP. But learning JSP is difficult than PHP and ASP.

One of my thinking is that the configuration of the JSP server environment is to be difficult. For dynamic web production, when the ASP ASP is very long

It is a "master" that occupies the wind, not much "master" (maybe a lot of people think that the JSP is the master.) Use JSP, the intersection is successful.

JSP website such as Century Star Network (Tomcat), Network Education Institute website (RESIN), Jiaotong University Admissions Employment Network (Tomcat), server is

Linux 9, running relatively stable and reliable. The apache and tomcat under Linux I have sent an article.

Everyone must search in Jincheng. LINUX and Windows are the same under the integration ideas, using Apache to resolve * .html / *. htm

Static web page, when you encounter * .jsp and servlet, throw the JSP page to Tomcat through Module in an Apache.

RESIN is handled, to make this module by compiling under Linux, you have to trouble, this article is in the ready-made WIN

Module to complete the integration.

Don't say nonsense, below the integration:

Required software

(1) J2SDK-1_4_2-windows-i586.exe

JDK version is not very large, does not affect the integration of Apache and Tomcat, pay attention to some of the environments when configuring environment variables.

(2) Apache_2.0.49-win32-x86-no_ssl.exe

The Apache version is not too big to integrate, but it is best to take advantage of this release.

(3) JAKARTA-TOMCAT-4.1.30.EXE

The version is best to use this version, and I have not tried other things, it may cause integration unsuccessful.

(3) PHP-4.3.3-win32.zip

It is a compressed package, download it directly to decompress it.

(4) MOD_JK.DLL

This module is placed in the Module in Apache, using it to communicate between Tomcat and Apache.

(5) MySQL-MAX-3.23.46A-WIN.ZIP

Database mysql, its version has little impact on integration.

(6) JDBC driver

MySQL drivers, and use of databases

I don't put down the address of Down, go online, I will find it, I should find it with my heart.

Not big, if you can't find it, let me find it.

I. Install J2SDK

Under Windows, run the downloaded J2SDK-1_4_1_01-windows-i586.exe file directly, install it to a directory according to the installation wizard, such as D: / Server / J2SDK

1. Configure environment variables:

Add a ClassPath variable

Variable value

............................. ..

D: /server/j2sdk1.4.0/bin

This configuration ensures that the Class class can be found when Java is run.

2. Add a java_home variable, the variable value is d: /server/j2sdk1.4.0

3. In the original PATH variable, add D: /Server/J2SDK1.4.0/bin, so that you are running in order to run the Java alignment.

Restart

CMD enters DOS, runs Java and Javac to see if there is any reaction, if the command is helpful, then Java is successful.

You can also run a Java applet.

Public class test {

Public static void main (string args []) {

System.out.println ("See this note Java installation success!");

}

}

Store on the Test.java file on the program, must be Test.java, then use command to compile

Javac Test.java

If there is no error, it means that the compilation is successful. If it is wrong, on the basis of the program writing correctly, just explain that the Java environment variable is not

There is a configuration, just configure it. If the compilation is successful, run:

Java Test

Attention, not Java Test.java! If it is correct, just print:

See this explanation Java installation is successful!

Gxgx, JDK installation is successful! You can carry it next.

Two .apache installation

1. Run apache_2.0.49-win32-x86-no_ssl.exe, all the way "OK" and "Accept" in line, path selection

D: / Server / apache group / apache2.

At this point Apache is already installed, and it has been run, and http: // localhost / can be seen in IE.

Apache's home page. Successful installation!

2. Modify httpd.conf

Apache's configuration file is httpd.conf, under the CONF folder under the Apache root directory

(1). Modify the default website root directory:

Create a folder WWW under D: / Server to use this as the root of the website

DocumentRoot "D: / Server / Apache Group / Apache2 / HTDOCS"

Change to DocumentRoot "D: / Server / WWW

(2). Modify character settings

Apache will generate garbled when resolving Chinese webpages,

Modify AddDefaultcharset ISO-8859-1 is AddDefaultCharset GB2312

(3). Modify the default homepage

When accessing the directory, Apache will automatically import the home page, priority is subject to the order

Change DirectoryIndex INDEX.html Index.html.var to

DirectoryIndex index.html index.jsp index.php default.jsp default.php index.html.var

(4). Set the error page

This will be more secure for your website. If you don't set it, others will enter a path after your URL, and 404 faults will be displayed.

Mistaken, and will display your server version number, the server configuration is at a glance, in order to avoid this, you can set the error page. When a 404 error occurs, the visitor imports the visitor into an error page.

turn up:

#

# Customizable Error Responses COME IN Three Flavors:

# 1) Plain TEXT 2) Local Redirects 3) External Redirects

#

# Some Examples:

#Errordocument 500 "The Server Made A Boo Boo."

#Errordocument 404 /missing.html

#Errordocument 404 "/cgi-bin/missing_handler.pl"

#Errordocument 402 http://www.example.com/subscription_info.html

#

This section in httpd.conf, # errordocument 404 / confissing.html

One way to modify it to ErrorDocument 404 / Error/nofile.htm, where nofile.htm is D: / Server / WWW / Error / next error file,

Establish yourself. When a 404 error occurs, enter the Nofile.htm page, you can prompt the web page. This is impossible to see

Your server software information is. You can also set other error-oriented pages, please refer to the relevant information for the specific HTTP response error number.

Restart Apache, if there is no accident, it is already installed, put the static page into the D: / Server / WWW / Error / Directory, see if you can successfully resolve.

Just enter one: http://localhost/sdagasgdasaSg.htm, see if it is directed to 404 errors, namely the Nofile.htm Error page.

Successful!

Regarding the meaning of other parameters in Apache, I don't say it, you can go online, in fact, the best way is to see the comment in httpd.conf

Divided, it is very clear.

Ok, go to this apache installation, you can take a break, listen to the first music, start the next step :)

3.PHP installation

Unzip php-4.3.3-win32.zip, to the D: / Server / PHP directory. Configure PHP and Apache to make it able to resolve PHP programs.

Remove "php.ini-dist" in the D: / Server / PHP / directory "php.ini" and copy it to C: / Windows / System32

(Win2K directory is: C: / WinNT / System32), in the following lines in the Apache's configuration file httpd.conf, make it

Support PHP.

Scriptalias / PHP / "D: / Server / PHP /"

AddType Application / X-httpd-php .php3

AddType Application / X-httpd-php .php

AddType Application / X-httpd-php .phtml

Action Application / X-httpd-php "/ php/Php.exe"

Create a web page under D: / Server / WWW: Index.php, the content is:

PHP test </ title> </ head></p> <p><? PHP</p> <p>PHPINFO ();</p> <p>?></p> <p></ html> Editing the text editor to save it as index.php, restart Apache, enter http://localhost/index.php in IE, if PHP appears</p> <p>Environment variables, illustrate PHP, successful installation, if you cannot resolve <? Php phpinfo ();?> The part is not successfully installed.</p> <p>Four. Tomcat installation</p> <p>I use jakarta-tomcat-4.1.30.exe installation file, "OK" in Windows, "OK", relatively simple, installation directory is</p> <p>D: / server / Tomcat</p> <p>Set the environment variable below:</p> <p>With the jdk environment variable, add variable tomcat_home, value D: / Server / Tomcat; increase variable Catalina_Home, value is</p> <p>D: / Tomcat / Server, add D: / Server / Tomcat / Bin in the PATH variable</p> <p>Let's start Tomcat, run down the Tomcat directory, bin / startup.bat file, the Tomcat running console, Tomcat success</p> <p>start up.</p> <p>Enter http: // localhost: 8080 /, see big cats, then Tomcat is successful.</p> <p>5. Install mysql</p> <p>Step 1: Unzip mysql-max-3.23.46a-win.zip, run the mysql installation file, install MySQL to D: / Server / MySQL</p> <p>Step 2: Add D: / Server / MySQL / BIN in the environment variable PATH</p> <p>Step 3: Enter the D: / Server / MySQL / BIN directory, run Winmysqladmin, just show the dialog box, set the mysql user password, assume</p> <p>The account is: root password is: 123</p> <p>Step 4: Enter DOS, enter mysql / bin, run the following command to open mysql</p> <p>MySQLD-NT --STANDALONE</p> <p>Then MySQL is turned on</p> <p>Then run:</p> <p>mysql</p> <p>If open, the following text appears:</p> <p>Welcome to the mysql monitor. Commonds end with; or / g.</p> <p>Your MySQL Connection ID IS 1 TO Server Version: 3.23.46-NT</p> <p>Type 'help;' or '/ h' for help. Type '/ c' to clear the buffer.</p> <p>MySQL></p> <p>Note: At this time, Mysql does not set a password. In order not to let others enter your database, please set your password for mysql. For details, see mysql</p> <p>Chinese explanatory documentation.</p> <p>At this point, MySQL is installed!</p> <p>6. Install the driver class JDBC for mysql</p> <p>Unlock the JDBC driver package, copy the ORG folder inside to the position where the JSP can find it. Can be Tomcat's root directory Common / Classes</p> <p>Under the folder, you can also be a JSP website Class class Web-INF / CLASS / under. When the driver is loaded, it can find the associated class. Or put a JDBC package</p> <p>The path is added to the ClassPath variable.</p> <p>Seven.Tomcat and Apache integrated configuration</p> <p>Tomcat is just a container used to resolve * .jsp files, it is not a server, and its ability to resolve static HTM / HTML file is far less than Apache,</p> <p>After the integration, the Apache is parsed in the same port, and when you encounter * .jsp web pages, it will be parsed by Tomcat.</p> <p>Step 1: Copy mod_jk.dll to the Apache root directory Module folder. Step 2: Configure Apache</p> <p>Open the Apache root directory conf / httpd.conf</p> <p>Add the following statement:</p> <p># ------------------------------------------</p> <p>#Connecting to Tomcat Using AJP13</p> <p>LoadModule JK_Module Modules / MOD_JK.DLL</p> <p>JKWorkersFile "D: /serVer/tomcat/conf/Workers.properties"</p> <p>JKMOUNT / Servlet / * ajp13</p> <p>JKMount /*.jsp Ajp13</p> <p># ------------------------------------------------- ----</p> <p>Note: The basic meaning of the above statement is:</p> <p>LoadModule One line: Load MOD_JK.DLL Dynamic Link Link Library Module, make it communicated with Tomcat</p> <p>JKWORKERSFILE: Tomcat related files in Tomcat related files in Workers.properties</p> <p>JKMount: The two lines indicate that when they encounter * .jsp and servlet, they will be transferred to the AJP13 protocol and then forward to Tomcat processing.</p> <p>Step 3: Establish a workers.properties file, establish a workers.properties file under the Tomcat root directory confes, the content is:</p> <p>Workers.tomcat_home = D: / Server / Tomcat</p> <p>Workers.java_home = d: /server/j2sdk1.4.0</p> <p>PS = /</p> <p># Worker.list = ajp13</p> <p>Worker.list = ajp12, ajp13</p> <p>Worker.ajp12.port = 8007</p> <p>Worker.ajp12.host = localhost</p> <p>Worker.ajp12.type = ajp12</p> <p>Worker.ajp12.lbFactor = 1</p> <p>Worker.ajp13.port = 8009</p> <p>Worker.ajp13.host = localhost</p> <p>Worker.ajp13.type = ajp13</p> <p>Worker.ajp13.lbFactor = 1</p> <p>Worker.loadbalancer.Type = LB</p> <p>Worker.loadbalancer.balanced_Workers = AJP12, AJP13</p> <p>Worker.inprocess.type = jni</p> <p>Worker.inprocess.class_path = $ (workers.tomcat_home) $ (ps) class Classes</p> <p>Worker.inprocess.class_path = $ (workers.tomcat_home) $ (PS) LIB $ (PS) jaxp.jar</p> <p>Worker.inprocess.class_path = $ (workers.tomcat_home $ (ps) lib $ (ps) Parser.jar</p> <p>Worker.inprocess.class_path = $ (workers.tomcat_home) $ (PS) Common $ (PS) LIB $ (PS) Jasper.jar</p> <p>Worker.inprocess.class_path = $ (workers.tomcat_home) $ (ps) Common $ (PS) LIB $ (PS) servlet.jar</p> <p>Worker.inprocess.class_path = $ (workers.tomcat_home) $ (PS) Common $ (PS) LIB $ (PS) WebServer.jar</p> <p>Worker.inprocess.class_path = $ (workers.java_home) $ (ps) lib $ (ps) Tools.jarWorker.inProcess.cmd_line = -config</p> <p>Worker.inprocess.cmd_line = $ (workers.tomcat_home /conf/jni_server.xml</p> <p>Worker.inprocess.cmd_line = -home</p> <p>Worker.inprocess.cmd_line = $ (workers.tomcat_home)</p> <p>Worker.inprocess.jvm_lib = $ (workers.java_home) $ (PS) JRE $ (PS) BIN $ (PS) Classic $ (PS) jvm.dll</p> <p>Worker.inprocess.stdout = $ (workers.tomcat_home) $ (ps) inProcess.stdout</p> <p>Worker.inprocess.stderr = $ (workers.tomcat_home) $ (ps) inProcess.stderr</p> <p>Worker.inprocess.sysprops = tomcat.home = $ (workers.tomcat_home)</p> <p>Note that the above files are first, the second line fill in the relevant directory of Tomcat and JDK.</p> <p>Step 4: Configure the server.xml file under Tomca / Conf. This is the main configuration file of Tomcat, and the important configuration is as follows:</p> <p>1. Virtual directory settings:</p> <p>Find below:</p> <p><Host name = "localhost" debug = "0" AppBase = "/ webApps"</p> <p>Unpackwars = "true" autodeploy = "true"></p> <p>change into:</p> <p><Host name = "localhost" debug = "0" AppBase = "D: / Server / WWW"</p> <p>Unpackwars = "true" autodeploy = "true"></p> <p>Make the Tomcat home directory to D: / Server / WWW.</p> <p>Find below:</p> <p><Context path = "examples" DOCBASE = "/ example" debug = "0"</p> <p>Reloadable = "true" crossText = "true"></p> <p>change into</p> <p><Context path = "" DOCBASE = "/" debug = "0"</p> <p>Reloadable = "true" crossText = "true"></p> <p>This is what I should be the JSP of the Tomcat root directory as a virtual host.</p> <p>2. Set the Tomcat listening port and find the following:</p> <p><Connector classname = "org.apache.coyote.tomcat4.coyoteconnector"</p> <p>Port = "8080" MINPROCESSORS = "5" maxprocessors = "75"</p> <p>Enablelookups = "True" redirectport = "8443"</p> <p>Acceptcount = "100" debug = "0" connectionTimeout = "0" UseriValidationHack = "false" disableuploadTimeout = "true" /></p> <p>The default port is 8080, but this everyone knows, it is best to modify it, assume that it is modified to: 8123, then the following:</p> <p><Connector classname = "org.apache.coyote.tomcat4.coyoteconnector"</p> <p>Port = "8123" MINPROCESSORS = "5" maxprocessors = "75"</p> <p>Enablelookups = "True" redirectport = "8443"</p> <p>Acceptcount = "100" debug = "0" connectionTIMEOUT = "0"</p> <p>Useurivalidationhack = "false" disableuploadtimeout = "true" /></p> <p>3. Find the following 8009 port, this is very important, pass 8009, Tomcat and Apache, if the following part</p> <p>Note by <! ---->, must remove it <! ---->.</p> <p><! - Define a coyote / jk2 ajp 1.3 Connector on port 8009 -></p> <p><Connector classname = "org.apache.coyote.tomcat4.coyoteconnector"</p> <p>Port = "8009" MINPROCESSORS = "5" maxprocessors = "75"</p> <p>Enablelookups = "True" redirectport = "8443"</p> <p>Acceptcount = "10" debug = "0" connectionTIMEOUT = "0"</p> <p>Useurivalidationhack = "false"</p> <p>ProtocolHandlerclassName = "org.apache.jk.server.jkcoyotehandler" /></p> <p>Step 5: Configure Tomcat's conf / web.xml file:</p> <p>Similar to the configuration of the 404 error page under Apache, add the following before the last </ web-app>:</p> <p><Error-Page></p> <p><Error-Code> 404 </ ERROR-CODE></p> <p><location> / error/nofile.htm </ location></p> <p></ Error-Page></p> <p><Error-Page></p> <p><exception-type> java.lang.nullpointerException </ exception-type></p> <p><location> / error/error.jsp </ location></p> <p></ Error-Page></p> <p>The first <error-page> </ error-page> is 404 unfounded error-oriented pages that do not find the JSP page, when 404 errors, web pages are guided to / error/nofile.htm, or similar approaches Add its multi-error code orientation page.</p> <p>The second <error-page> </ error-page> is when java.lang.nullpointerException is often sent to the JSP page.</p> <p>Guide to the / error/error.jsp error page. Then you need to add the following in the first JSP page:</p> <p><% @ Page ErrorPage = "/ Error / Error.jsp"%></p> <p>A typical error.jsp error page is written as follows:</p> <p><% @ Page ContentType = "text / html; charset = GB2312"%></p> <p><% @ Page isrrorpage = "true"%></p> <p><html></p> <p><head> <title> Error page </ title> </ hEAD></p> <p><body></p> <p>Error: </ p> error message: <% = exception.getMessage ()%> <br></p> <p>Stack TRACE IS: <pre> <font color = "red"> <%</p> <p>Java.io.chararraywriter CW = new java.io.chararraywriter ();</p> <p>Java.io.printwriter PW = new java.io.printwriter (CW, true);</p> <p>Exception.PrintStackTrace (PW);</p> <p>Out.println (cw.toString ());</p> <p>%> </ font> </ pre></p> <p></ body></p> <p></ html></p> <p>Tomcat is imported into Error.jsp when nullpointerexception is often the NullPointersRexception exception.</p> <p>The fifth step is mainly safety considerations. Under normal circumstances, if you can't find a web page, 404 errors or JSP programs have an error, at the client</p> <p>It will list information similar to the following information (Tomcat as an example, RESIN):</p> <p>Http status 404 - /sdags.jsp</p> <p>-------------------------------------------------- ------------------------------</p> <p>Type Status Report</p> <p>Message /sdags.jsp</p> <p>Description The Requested Resource (/SDags.jsp) Is Not Available.</p> <p>-------------------------------------------------- ------------------------------</p> <p>Apache Tomcat / 5.0.19</p> <p>This way the server version will be seen by others. If the configuration of the fifth step is completed, this will not happen.</p> <p>Step 6: Configure httpd.conf files</p> <p>This method sets Tomcat and Apache's root directory, but must restrict access to some files in the directory, such as depositing Class</p> <p>Web-INF, add the following code to httpd.conf:</p> <p># dey the access to web-infers</p> <p><Directory ~ "/ Web-INF /"></p> <p>ORDER ALOW, DENYDENY from ALL</p> <p></ Directory></p> <p>This way, when trying to ask Http: // localhost / web-inf //, apache will refuse.</p> <p>To this, Tomcat and Apache are integrated. Restart Tomcat and Apache,</p> <p>Put the JSP page in D: / Server / WWW / under, for example:</p> <p><html></p> <p><H1> JSP Test <HR></p> <p><% OUT.PRINTLN ("Hello World!");%></p> <p></ html></p> <p>Save as index.jsp, type http: // localhost: 8123 / index.jsp in IE</p> <p>If there is a</p> <p>Hello World!</p> <p>Just indicated that Tomcat is operating normally, enter http://localhost/index.jsp: //localhost/index.jsp, if</p> <p>Hello World!</p> <p>Congratulations! Integration is successful, you take a big step on the road of JSP's long hardship ~!</p> <p>I am done in the rush time, and maybe some errors. Or consider where you are in a place, but overall should not</p> <p>Too big, I repeatedly used this method to integrate success. If you have any questions, you can contact me directly.</p> <p>Moonsbird: mail: pengw97@163.com</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-48279.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="48279" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.040</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'W_2F5VEBfiOP8k3kQi_2FmZKhfYej_2F1KZX362N8RTSbBDRZcqkRiPE5oQWMX7pjU3_2BCurPRDY8xACOJYkKSFpEagew_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>