Java servlet uploads CentOS server

Source: Internet
Author: User
Tags centos server

The previous essay said that the method of setting up Javaweb running environment on CentOS, this article mainly talk about packing and uploading server.

One, database connection file. propeties

For database security, mysql3306 port access I made IP access restrictions, because MySQL and web sites are on a server, so when uploading we will modify IP to-->localhost

Second, webxml configuration

This is mainly the role of the label in Webxml.

The main labels in webxml are three---><servlet> <servlet-mapping> <welcome-file-list>

Where <servlet> and <servlet-mapping> are paired.

1. <servlet> Label

The <servlet-name> tag in the <servlet> tag is the package name, see the first step in the "1"

The <servlet-class> in the <servlet> tag is the servlet class under the package name, see the second step in "1", where the previous one is the package name, the next one is the class name, So to Servlet.servlet

2. <servlet-mapping> Label

The <servlet-name> tag in the <servlet-mapping> tag is also the package name , see the first step in the "1"

The <url-pattern> tag in the <servlet-mapping> tag is the mapping address of the set Servlet.java (Access address)

3. <welcome-file-list> Label

This tag is the default access page to set the Java EE startup, see Fourth Step "4" in the index.jsp, (here JSP can also create HTML page) Of course this page is used for JSP, if we are only write Servlet interface can not create. JSP page.

Three, packaging. War file

Operation Steps: Check servletdemo--> (servlet project), right mouse button Select Export--> Select War-file Enter the above ... Destinaborc fill in the path where you saved the. War.

Iv. downloading FTP, setting up, uploading

I use the FLASHFXP here, this tool is charged, but I found a no need to crack can always be free to use the method, if the use period of nearly 30 days, you can use 360 to uninstall this tool, and then reinstall ...

: direct Baidu input FLASHFXP5.

/home/represents your path to installing Tomcat on CentOS---> Step 2

1. Upload the package file. War

Follow the steps above, log in to the Tomcat installation path---Click-to-top, and then upload the. War to the WebApps path.

2, decompression. War

Decompression is simple, only need to close Tomcat under CentOS, and then restart, the war will be automatically extracted.

Specific procedures:

Above first you have to login to your CentOS server and then go to the Tomcat bin file to execute the last sentence ./shutdown.sh--> enter (stop Tomcat)

Then execute-->./startup.sh (start tomcat again) and your. War file will be unzipped to the WebApps folder.

So you can access your uploaded website by http//your ip:8080/unzipped folder.

Http://120.25.227.133:8080/servletdemo/--> But if the default input folder name is accessed by the Webxml in the index.jsp page.

If you want to access the servlet page you write need input, webxml inside the corresponding map address-"http://120.25.227.133:8080/ServletDemo/2.jsp."

The last thing to remember is that if you develop a servlet that uses a third-party package, you must upload the third-party package via FTP to the Tomcat Lib folder.

Java servlet uploads CentOS server

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.