CSCI 6962: Serverside Development and Programming - PowerPoint PPT Presentation

1 / 42
About This Presentation
Title:

CSCI 6962: Serverside Development and Programming

Description:

print ' widgets!'; print ' /BODY /HTML '; Web Containers ... Microsoft IIS. Visual Basic/Visual C /C#. Active Server Pages. Downloading the Java SDK ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 43
Provided by: csis8
Category:

less

Transcript and Presenter's Notes

Title: CSCI 6962: Serverside Development and Programming


1
CSCI 6962 Server-side Development and Programming
  • Lecture 2 The Jakarta Tomcat Web Container and
    the NetBeans IDE

2
Client-Server Web Architecture
  • Client browser sends request for page to server
  • Server sends response page and sends to client

Client
Browser
Response containing Syllabus.htm as a long string
(lthtmlgtltheadgtlttitlegtCSCI 6962 Syllabuslt/titlegtlt/he
adgtltbodygt)
www.cis.ysu.edu/john/Syllabus.htm
port
Request to www.cis.ysu.edu for Syllabus.htm
Server john public_html Syllabus.htm
3
Form Handling
  • Server must
  • Listen on port for requests
  • Parse request to determine values of parameters
  • Generate appropriate response page based on
    parameter values
  • Send response page back to client

4
Simple perl cgi-bin Program
  • !/opt/local/bin/perl
  • program to print back results of test form
  • parse input string into an associative list
  • _at_pairssplit(//, ENV'QUERY_STRING')
  • foreach pair (_at_pairs)
  • _at_itemsplit(//, pair)
  • key_at_item0
  • value_at_item1
  • formdatakeyvalue
  • print response to form
  • print "Content-type text/html\n\n"
  • print "ltHTMLgtltHEADgtltTITLEgtcgi-bin
    responselt/TITLEgtltBODYgt"
  • print "Thank you for your order of "
  • print formdata"quantity"
  • print " widgets!"
  • print "lt/BODYgtlt/HTMLgt"

5
Web Containers
  • Program running continuously on server
  • Runs code to handle requests
  • Built-in methods for parsing requests, generating
    responses
  • Handles other important functions
  • Session tracking
  • Database access
  • Email generation
  • Security and encryption

6
Web Containers
  • Jakarta Tomcat
  • Written in Java
  • NetBeans IDE
  • Acts as engine for Java Server Pages and servlets
  • Microsoft IIS
  • Visual Basic/Visual C/C
  • Active Server Pages

7
Downloading the Java SDK
8
Downloading the Java SDK
9
Downloading the Java SDK
10
The NetBeans IDE
  • Integrated Development Environment for Java
    Programming
  • Editing code (with hints)
  • Compiling code
  • Running code
  • Good for JSP/servlet development
  • Allows easy development of web applications
  • Has own version of Tomcat for testing
  • Automatically interacts with external Tomcat
  • No need to manipulate Tomcat file structure

11
Downloading NetBeans
12
Downloading NetBeans
13
Downloading NetBeans
  • Note NetBeans has built-in Tomcat server

14
Creating a Web Application
  • In NetBeans File ? New Project
  • Choose Web and Web Application

15
Creating a Web Application
  • Give your project a name (I called this one
    WidgetSite)
  • Give it a location (I have put it in a directory
    called 6962)
  • Make sure it is set as the Main Project

16
Creating a Web Application
  • The final page shows information (such as which
    server this project uses)
  • Can change to external server if desired

17
Creating a Web Application
NetBeans creates an initial web site
Structure shown in the project window
Creates an initial index.jsp page (default home
page of the new site)
The index.jsp is initially just a Hello world
page
18
Running a Web Application
  • Running the site opens the index.jsp page
  • Can choose browser (and should test with all!)

19
Building a Web Application
  • Modify and add files to create web site

index.jsp Prompts user for number of widgets
reciept.jsp Displays number of widgets purchased
20
Building a Web Application
21
Adding a JSP
Choose a JSP
  • File ? New

Give it a name
22
Running the Site
Compiles and runs current webapp (starting Tomcat
and opening browser)
23
Installing Tomcat
  • Detailed Instructions in Chapter 2 (page 31)
  • Copy JAR files from Tomcat to Java Runtime
    Environment
  • Necessary for JSPs and servlets to compile

24
Installing Tomcat
  • Tell Tomcat where to look for Java (page 34)
  • Edit catalina.bat file in bin directory of Tomcat

25
Installing Tomcat
  • Add user in management role (page 50)
  • Edit tomcat-users.xml file in conf directory of
    Tomcat

26
Testing Tomcat
  • Start Tomcat
  • Execute startup.bat in bin directory

27
Testing Tomcat
  • This will open Tomcat control window
  • Note Should not have NetBeans and Tomcat running
    simultaneously (both try to use same port)

28
Testing Tomcat
  • Tomcat is now listening for requests!
  • Listening at port 8080 by default
  • Test enter http//localhost8080/ in your browser

29
Tomcat Structure
  • Listens on port 8080 for requests
  • Retrieves page requested
  • Must be part of its file structure in webapps
    directory
  • Example http//localhost8080/
  • Sends request to this machine for index.html file
    in ROOT subdirectory of webapps

30
Tomcat Structure
  • Another example http//localhost8080/examples/js
    p/simpletag/foo.jsp

31
Tomcat Structure
  • Side point JSPs/servlets can display messages
    in Tomcat window (often used for diagnostics)

32
Tomcat Structure
  • Meaning of this URLhttp//localhost8080/example
    s/jsp/simpletag/foo.jsp

Invoke server listening on port 8080 of this
machine
Access this file in this subdirectory of the
tomcat/webapps directory
33
Tomcat Structure
  • Side note Usually refer to server on another
    machine http//www.cis.ysu.edu/examples/jsp/simple
    tag/foo.jsp
  • For testing, often run client and server on same
    machine

Invoke server at this remote URL
Access this file in this subdirectory of the
tomcat/webapps directory
Port 8080
request
Tomcat
response
Browser
request
http//localhost8080/...
response
34
Tomcat Structure
  • If requested page is server page/servlet,
    executes code embedded in page to generate
    corresponding html page
  • Final html page sent as response

35
Adding a Tomcat Server
  • Tools ? Servers
  • Press

36
Adding a Tomcat Server
  • Select Tomcat 6.0
  • Give it a name otherthan Tomcat 6.0

37
Adding a Tomcat Server
  • Enter the directorywhere you installed Tomcat
  • Enter a name and a password for amanager
    role(we will use thismore later)

38
Adding a Tomcat Server
  • By default, Tomcat listens at port 8080

39
Adding a Tomcat Server
  • Change server used by your webapp
  • File ? Project Properties
  • Choose Run propertiesand select the external
    server

40
Deploying your Site to Tomcat
  • Right-click project and choose Deploy
  • This copies all web site files into build\web
    subdirectory

41
Deploying your Site to Tomcat
  • Copy these files into a subdirectory of webapps
    in Tomcat

42
Deploying your Site to Tomcat
  • Start Tomcat (after closing NetBeans)
  • Go to http//localhost8080/WidgetSite in browser
Write a Comment
User Comments (0)
About PowerShow.com