Presentation is loading. Please wait.

Presentation is loading. Please wait.

Standalone Java Application vs. Java Web Application

Similar presentations


Presentation on theme: "Standalone Java Application vs. Java Web Application"— Presentation transcript:

1 Standalone Java Application vs. Java Web Application
A class that contains a main() method must be the initial class invoked for a standalone application. Invoked with the java command, which automatically calls the main() method. Does not have to be invoked within a special environment. Java web application Servlets are the initial classes invoked for Java web applications. Servlets are Java classes that extend the Servlet class. They contain methods that correspond to HTTP request types such as doGet() and doPost(), and their initial method is service() rather than main(). Invoked in a special environment called a servlet container which is part of a web app server. Upon receipt of an HTTP request, the container automatically calls the proper method that corresponds to the type of HTTP request received. When an application framework is used, the framework provides the servlets that handle the initial receipt of HTTP requests, so developers only write normal Java classes and JSPs.

2 Standalone Java Application Environment
OS/400 Java Runtime Environment Library (JRE) Java Virtual Machine (JVM) Java Application

3 Java Web Application Environment
OS/400 JRE Library Http Server JVM J2EE Application Server Java Servlet v2.3 Container Web App Web App Web App Multi-user User authorization and access control Maintain session state via cookies or URL rewriting Multi-tasking Time-slice control Resource pool management Threads Class instances SQL prepared statements Database connections

4 Configuring Web Applications On The Server
There can be multiple web applications installed on the same application server. Each has a unique name (application context): GlazerWeb AllianceReports AllianceUserMaint diveport GlazerTest Each has a configuration file (web.xml): Specifies the index (initial) page Specifies mappings of URL requests to servlets One URL to one servlet Group of URLs to one servlet

5 Java Application Frameworks
An application framework provides: Process flow control (MVC) Helper processes (instantiate and auto-populate classes and beans, and populate and extract data for html page fields) Functional processes (validation, database access) Configuring a web application that uses a framework: In the web application configuration file (web.xml), all requests map to the framework controller servlet so the framework can control the flow. Each application requires additional configuration files to specify the desired behavior of the framework. Configuration file for application framework Requested URL Classes Form View Validation Error View Auxiliary 1 Auxiliary x Controller Success View promptForm ClassA ClassB ClassA ClassD ClassE ClassF detailForm detailForm ClassA ClassB ClassA ClassD ClassE ClassF promptForm

6 Web Application Flow (using an MVC framework)
Request arrives at HTTP server. HTTP server routes the request to the application server. Based on the application context, the requested URL is compared to the configuration file for the application and the request is passed to the specified servlet (the framework controller). Framework controller looks up the entry for the requested URL in the framework configuration file for the application, and based on the configuration parameters: Request is passed to the form view class after executing any helper classes and instantiating any beans. View class creates and sends response to the user. User sends reply request. Based on the session id cookie, the server associates the request to the existing session for the user. Framework populates a bean with the input data from the request. Framework executes validation class. If validation errors, framework: Returns the input data and all errors to the form view class. If no validation errors, framework: Instantiates and populates any helper classes and beans. Passes the request to the controller class for the requested URL. At end of controller class execution, the request is passed to the success view class. Success view class creates and sends response to the user.


Download ppt "Standalone Java Application vs. Java Web Application"

Similar presentations


Ads by Google