WebLogic Server 6.0.0 Code Examples, BEA Systems, Inc.

Package examples.jsp

These examples show how to use JSP to generate dynamic content in web pages.

See:
          Description

JSP Examples Summary
EasyTableDataDisplay This example shows how to create an HTML table from a dbKona TableDataSet. The example uses an htmlKona feature that automatically creates an HTML table from a JDBC DataSet.
EJBeanManagedClient This example demonstrates using JSP to call a WebLogic EJBean, how to use an EJBean from within a scriplet page. It uses a beanManaged entity EJBean included with the WebLogic Distribution. Before you try to run this example, you'll need to compile, configure, and deploy the EJBean that this example depends upon; please see the beanManaged persistence example and the WebLogic EJBean examples for instructions.
ErrorPage Demonstrates how to set up an error page for a JSP page. Do not load this JSP directly in your browser. This file is instead called by the ThrowException.jsp example.
HelloWorld This simple example demonstrates how to embed Java in a JSP page.
InteractiveQuery Connects to a database, and displays it's contents in a table. You can click on an entry in the table, which makes another query to this JSP page. The page interprets the request differently since there are HTTP query parameters present, and displays the name of the entry you selected.
JdbcTable Shows how to use a form to set options for retrieving database data from a table with JDBC. This example uses the demoPool JDBC connection pool.
SessionServlet Shows how to store and retrieve user data in a session. The example allows you to add or delete name/value attributes to and from an HTTP session, much the same as a shopping cart would work. The same session containing the user values is retrieved each time the browser revisits the web page, and is displayed in a list. This is achieved using session cookies. For more details, see the section on sessions in Programming WebLogic HTTP Servlets.
ShowDate Demonstrates importing a package (java.util.Date) into a JSP page, setting a response header attribute, and using a JSP expression tag.
SimpleDBLogin Illustrates how to make a connection to a database with JDBC, including exception handling to help you debug your servlet. This example uses the "demoPool" JDBC connection pool.
SimpleSession This example shows simple principles of session management by incrementing a counter each time a user accesses a page.
SnoopServlet This example lets you examine HTTP data about the servlet itself.
ThrowException Demonstrates how to set up an error page for a JSP page. Here, ErrorPage.jsp is returned when an uncaught exception is thrown in the ThrowException.jsp page.
URLEncode Demonstrates using URL rewriting to pass session information to the server from browsers that do not support cookies.
Using JSP Custom Tag Libraries A set of examples that demonstrate using custom JSP tags and how to create the Java classes for the tags.
 

Package jsp Description

These examples show how to use JSP to generate dynamic content in web pages. JSP allows you to concentrate on the design of HTML pages, but still use Java to provide the dynamic content and logic. These examples demonstrate:

In addition to the preceding examples, JSP tag library extension examples are provided in the tagext subdirectory.

Perform the following steps to build and run the examples:

  1. Build the examples
  2. Configure the server
  3. Run the example

Build the Examples

  1. Set up your development shell as described in Setting up your environment for building and running the examples.

  2. Compile and copy all the .jsp files by executing the following commands or by executing the build script provided for this example in the samples/examples/jsp directory. The script will perform the following steps:

    1. Compile the JSP as shown in this example for Windows NT/2000:

      $ java weblogic.jspc -d %EX_WEBAPP_CLASSES% *.jsp

    2. Copy the .jsp files located in the samples/examples/jsp directory in your WebLogic Server installation to the config/examples/applications/examplesWebApp directory in your WebLogic Server installation. This directory is the location of the publically-available files of the examplesWebApp.

      $ copy *.jsp %APPLICATIONS%\examplesWebApp

Configure the Server

  1. Start the server with the examples configuration.

  2. Bring up the Administration Console in your browser.

  3. Make sure that the examplesWebApp is deployed on your server.

  4. Make sure that the demoPool JDBC connection pool is deployed on the "examplesServer" target. Use the WebLogic Server Administration Console to deploy this connection pool.

    Many of the examples use JDBC to access an example Cloudscape database called "demoPool." The Cloudscape DBMS is a Java database management system (DBMS) that is included with WebLogic Server, with a limited evaluation license. For more details on how to configure Cloudscape and the example "demoPool" database, see the tech-support document Using the Cloudscape database with WebLogic.

Run the Example

  1. Start the WebLogic Server in a new command shell.

  2. Use a browser to call the JSP page, with a URL that follows the pattern:
      http://WebLogicURL:WebLogicPort/examplesWebApp/jspExample.jsp
    For example, here's how you load the HelloWorld in a browser running on the same NT host as your WebLogic Server, on port 7001:
    http://localhost:7001/examplesWebApp/HelloWorld.jsp

There's More...


Documentation is available at
http://e-docs.bea.com/wls/docs60/

Copyright © 2000 BEA Systems, Inc. All rights reserved.