tomcat setup bcis 3680 enterprise programming. getting web apps to work verify that tomcat works. ...

15
Tomcat Setup BCIS 3680 Enterprise Programming

Upload: maryann-phelps

Post on 31-Dec-2015

239 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Tomcat Setup BCIS 3680 Enterprise Programming. Getting Web Apps to Work  Verify that Tomcat works.  Understand how context works.  Create folders/files

Tomcat Setup

BCIS 3680 Enterprise Programming

Page 2: Tomcat Setup BCIS 3680 Enterprise Programming. Getting Web Apps to Work  Verify that Tomcat works.  Understand how context works.  Create folders/files

2

Getting Web Apps to Work Verify that Tomcat works. Understand how context works. Create folders/files for easy deployment of

your web app. Configure server.xml. Configure web.xml. Test your web app.

Page 3: Tomcat Setup BCIS 3680 Enterprise Programming. Getting Web Apps to Work  Verify that Tomcat works.  Understand how context works.  Create folders/files

3

Verification of Tomcat Start a command prompt and run command: catalina run Tomcat is up if you see “INFO: Server startup in #### ms”

Page 4: Tomcat Setup BCIS 3680 Enterprise Programming. Getting Web Apps to Work  Verify that Tomcat works.  Understand how context works.  Create folders/files

4

Exiting Tomcat To exit Tomcat, get back to the command console. Press CTRL + C simultaneously. When asked whether to terminate batch job, type y and hit

ENTER. You often need to stop and restart Tomcat after making

changes to configurations or class files.

Page 5: Tomcat Setup BCIS 3680 Enterprise Programming. Getting Web Apps to Work  Verify that Tomcat works.  Understand how context works.  Create folders/files

5

Alias for Web App A web application consists of a collection of files that

are required to support a particular feature or task you want to publish to the outside world. The set of files are stored in a folder, which is the “deployment folder” for the application. It can contain subfolders.

When provide visitors with the URL to your web app, you don’t want to show them the physical path to the deployment folder.

Instead, you create an “alias” (or “context” or “virtual directory”) for the folder. In the URL, it is appended to the server name. Append any file names and/or subfolder names to the alias

when accessing files directly under the deployment folder or under one of its subfolders.

Page 6: Tomcat Setup BCIS 3680 Enterprise Programming. Getting Web Apps to Work  Verify that Tomcat works.  Understand how context works.  Create folders/files

6

Alias (Context)This is what you want

your visitors to type and see . The application appears to be the \

casej03 “subfolder” on the server (localhost in

this case)

Page 7: Tomcat Setup BCIS 3680 Enterprise Programming. Getting Web Apps to Work  Verify that Tomcat works.  Understand how context works.  Create folders/files

7

Deployment FolderThis is what your visitors DON’T see. This is where your web application files

are actually located at. You don’t want visitors to

know it.

Page 8: Tomcat Setup BCIS 3680 Enterprise Programming. Getting Web Apps to Work  Verify that Tomcat works.  Understand how context works.  Create folders/files

8

Folders for Deployment Inside the deployment folder, create a

subfolder called WEB-INF. For testing and assignments, download the web.xml file into this subfolder.

Page 9: Tomcat Setup BCIS 3680 Enterprise Programming. Getting Web Apps to Work  Verify that Tomcat works.  Understand how context works.  Create folders/files

9

Making the Connection

You define what you want the user to see (alias) as the

“path” attribute of the <Context> tag. Note the /

in front of the alias.

Set the value of the “docBase” attribute of the <Context> tag to

your deployment folder location.

For each alias, you need to add a new <Context> tag under the <Host> tag.

XML is case-sensitive!

Page 10: Tomcat Setup BCIS 3680 Enterprise Programming. Getting Web Apps to Work  Verify that Tomcat works.  Understand how context works.  Create folders/files

10

Setting Up a Context One way to define an alias (context) is do it in

the server.xml configuration file. server.xml is located in \<Tomcat Folder>\

conf\. In the course VM, it’s C:\Tomcat\conf.

You may use any editor that is capable of editing XML files to open it. In the course VM, use Notepad++. If you use Windows Notepad, you will need to open

it with administrator rights. Otherwise you won’t be able to save the changes you make.

Page 11: Tomcat Setup BCIS 3680 Enterprise Programming. Getting Web Apps to Work  Verify that Tomcat works.  Understand how context works.  Create folders/files

11

Start NotePad with Admin Rights

Again, open Notepad with administrator rights if you use Windows Vista or higher

Page 12: Tomcat Setup BCIS 3680 Enterprise Programming. Getting Web Apps to Work  Verify that Tomcat works.  Understand how context works.  Create folders/files

12

Start NotePad with Admin Rights

Page 13: Tomcat Setup BCIS 3680 Enterprise Programming. Getting Web Apps to Work  Verify that Tomcat works.  Understand how context works.  Create folders/files

13

Context for Web Applications Unlike HTML, XML is case-sensitive!

Inside the “Host” element (tag), modify the “Context” element. For example:<Context path="/jsp" docBase="E:/BCIS 3680/jsp" />

Restart Tomcat.

Page 14: Tomcat Setup BCIS 3680 Enterprise Programming. Getting Web Apps to Work  Verify that Tomcat works.  Understand how context works.  Create folders/files

14

Testing Web Site After you have complete all the previous

steps, you can verify whether your web site is up and running by:

First, start Tomcat server from command prompt.

Second, open the browser and enter the following URL:http://localhost:8080/<context>/default.htm Replace the <context> part with the alias you

defined in the server.xml file.

Page 15: Tomcat Setup BCIS 3680 Enterprise Programming. Getting Web Apps to Work  Verify that Tomcat works.  Understand how context works.  Create folders/files

15

Testing localhost Site Under Win7/Vista

1

23