Caucho maker of Resin Server | Application Server (Java EE Certified) and Web Server


 

Resin Documentation

home company docs 
app server 
 Resin Server | Application Server (Java EE Certified) and Web Server
 

applications


An application collects servlets, JSP pages, scripts and Java Beans into a self-contained web application. Applications are just generalized virtual hosts, only based on the URL instead of the host name.

Introduction

An application collects servlets, JSP pages, scripts and Java Beans into a self-contained web application. Applications are just generalized virtual hosts, only based on the URL instead of the host name.

For example, a bulletin board application groups pages for article reading, group listing, user registration, and new article posting into a single application.

Applications can keep track of user sessions, giving the users the illusion of a single application out of disjoint pages.

  • Resin organizes applications with an application directory, WEB-INF
  • Sessions share state for a user's visit to the site.

Many, if not most sites, will only use the default application.

Applications

application contents
FILE/DIRECTORYCONTENTS
.JSP, HTML and GIF files
WEB-INF/classesJava class files
WEB-INF/libJava jars
WEB-INF/tmpTemporary servlet files
WEB-INF/workGenerated java for JSP and XSLT
  •  example
    •  index.html
    •  folder.gif
    •  article.gif
    •  post-article.xtp
    •  jsp-interest
      •  index.jsp
      •  article1.jsp
      •  article2.jsp
    •  WEB-INF
      •  lib
        •  bulletin-board.jar
      •  classes
        •  Navigation.class
        •  HelloWorld.class
      •  xsl
        •  default.xsl
        •  article.xsl

JSP Beans

Java Beans get first class treatment in JSP 1.0. Beans can be created for a page, across a session, or for the entire application.

The classes and lib directories can contain application beans used by jsp:useBean. These are simply Java classes implementing the bitmechanic work of an application.

For example, a shopping cart application may have a set of Java classes that perform the security necessary for credit card processing. The application can put those classes in the beans directory and access them from the JSP page.

Beans can be created with different lifetimes.

  • Application beans last the lifetime of an application.
  • Session beans last for a user's session.
  • Request beans last for a single request.
  • Page beans only last for a single page.

Requests and pages often last the same lifetime, but may differ if one page forwards or includes another page.

Accessing Beans

Each bean is defined with a jsp:useBean directive.

JSP assigns the created bean object to the JavaScript variable named by jsp:useBean.

In addition, the created beans are stored in JSP variables: page beans are stored in request, session beans are stored in session, and application beans are stored in application. Storing the beans in the JSP variables lets other beans and functions retrieve the beans.

Beans in variables: test.jsp
<jsp:useBean id='test' class='java.util.Hashtable'>

&lt% test.put("a", 1); %>
&lt%= test.get("a"); %>
Page beans in request: test.jsp
<jsp:useBean id='test' class='java.util.Hashtable'>

<% 
  var t = request.attributes.test
  t.put("a", 1);
%>
&lt%= test.get("a"); %>
1

Sessions

Session variables let applications keep track of the user as she moves through the site. Any e-commerce site needs this capability to keep track of the user's purchases.

JSP sessions start when the page accesses the session variable.

Sessions end when the session times out, when the session is invalidated, or when the application ends.


Copyright © 1998-2015 Caucho Technology, Inc. All rights reserved. Resin ® is a registered trademark. Quercustm, and Hessiantm are trademarks of Caucho Technology.

Cloud-optimized Resin Server is a Java EE certified Java Application Server, and Web Server, and Distributed Cache Server (Memcached).
Leading companies worldwide with demand for reliability and high performance web applications including SalesForce.com, CNET, DZone and many more are powered by Resin.

home company docs 
app server