How to Configure Tomcat with Intellij By: Navjot S.Sandhu SW410 Enterprise Java Prof. Lyon.

14
How to Configure Tomcat with Intellij By: Navjot S.Sandhu SW410 Enterprise Java Prof. Lyon

Transcript of How to Configure Tomcat with Intellij By: Navjot S.Sandhu SW410 Enterprise Java Prof. Lyon.

Page 1: How to Configure Tomcat with Intellij By: Navjot S.Sandhu SW410 Enterprise Java Prof. Lyon.

How to Configure Tomcat with Intellij

By: Navjot S.SandhuSW410

Enterprise JavaProf. Lyon

Page 2: How to Configure Tomcat with Intellij By: Navjot S.Sandhu SW410 Enterprise Java Prof. Lyon.

Download Tomcat

• Download Application server from www.apache.org

• Make sure to set the appropriate Java Virtual Machine

Page 3: How to Configure Tomcat with Intellij By: Navjot S.Sandhu SW410 Enterprise Java Prof. Lyon.

Create a New Project in IntelliJ• Click File, then New Project• Create from Scratch• Click Next, give the Project a

Name, and keep Clicking Next until the Desired Technologies window is in front of you

• Click Web-Application, then Finish

Page 4: How to Configure Tomcat with Intellij By: Navjot S.Sandhu SW410 Enterprise Java Prof. Lyon.

Configure an Application Server in IntelliJ• Click File, then Settings• Click on Application Servers and Hit the

+ to add a new Tomcat Server• Set the Home Directory of the

application server you have just installed(ex: c:/Program Files/Apache Software Foundation/<Version>/ and then Click ok

Page 5: How to Configure Tomcat with Intellij By: Navjot S.Sandhu SW410 Enterprise Java Prof. Lyon.

Create New Class File(servlet)

Page 6: How to Configure Tomcat with Intellij By: Navjot S.Sandhu SW410 Enterprise Java Prof. Lyon.

Configure Application Server• Click on the run button, and then

then Edit Defaults• Click on the + in the top left hand

corner and add a Tomcat Server, then Local configuration

• Select the Tomcat in the pulldown menu next to Application Server

Page 7: How to Configure Tomcat with Intellij By: Navjot S.Sandhu SW410 Enterprise Java Prof. Lyon.

Configure App Server(cont.)

Page 8: How to Configure Tomcat with Intellij By: Navjot S.Sandhu SW410 Enterprise Java Prof. Lyon.

Configuration(cont.)

• Click on Deployment, WebFacets, and then the Web(inservlet) node and make sure the Deploy Web Facet radio button is checked

• Click on Configure and make sure the Web Deployment is configured correctly

Page 9: How to Configure Tomcat with Intellij By: Navjot S.Sandhu SW410 Enterprise Java Prof. Lyon.

Configuration(cont.)

Page 10: How to Configure Tomcat with Intellij By: Navjot S.Sandhu SW410 Enterprise Java Prof. Lyon.

Configuration(cont.)

Page 11: How to Configure Tomcat with Intellij By: Navjot S.Sandhu SW410 Enterprise Java Prof. Lyon.

Configure XML FIle

• Configure the web.xml file in the WEB-INF directory with the servlet class file name and directory, in this case we are going to place the class file in the root classes directory

Page 12: How to Configure Tomcat with Intellij By: Navjot S.Sandhu SW410 Enterprise Java Prof. Lyon.

Xml File(cont.)

• We have to add one of these for every class file

Page 13: How to Configure Tomcat with Intellij By: Navjot S.Sandhu SW410 Enterprise Java Prof. Lyon.

The Servlet Class

• Make sure to import the right classes and set the HTML output

Page 14: How to Configure Tomcat with Intellij By: Navjot S.Sandhu SW410 Enterprise Java Prof. Lyon.

Compile and Run

• Make sure to add the name of the Servlet, after Http://localhost:8080/servlet1 in the startup page parameter of the run screen

• Now we have an application server built into our development environement

• COOL!!!